Horje
list sort by key and value Code Example
list sort by key and value
# dictionary sort by key and value
d = { ' a ' : 4, ' b ' : 3, ' c ' : 2, ' d ' : 1 }
sort_by_key= sorted(d.items(), key = lambda x : x[0] )	    # [(' a ', 4), (' b ', 3), (' c ', 2), (' d ', 1)]
sort_by_value= sorted(d.items(), key = lambda x : x[1] )	# [(' d ', 1), (' c ', 2), (' b ', 3), (' a ', 4)]
print(sort_by_key)
print(sort_by_value)




Python

Related
rscript convert r to python script Code Example rscript convert r to python script Code Example
python tabulate without index Code Example python tabulate without index Code Example
ordered dictionary Code Example ordered dictionary Code Example
cython could not creat pyd file no such file or directory Code Example cython could not creat pyd file no such file or directory Code Example
ansible[azure] (azure >= 2.0.0)) on jenkins-node-Ansible-roles's Python /usr/bin/python3. Code Example ansible[azure] (azure >= 2.0.0)) on jenkins-node-Ansible-roles's Python /usr/bin/python3. Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8