Skip to content

Commit 5f33863

Browse files
Create sort_dict_by_value.py
sort a given dictionary according to values
1 parent 9605dcb commit 5f33863

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

programs/sort_dict_by_value.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
data = {
2+
'one':1,
3+
'two':2,
4+
'four':4,
5+
'three':3
6+
}
7+
8+
sort_dict = {key:val for key,val in sorted(data.items(),key= lambda x : x[1]) }
9+
print(sort_dict)

0 commit comments

Comments
 (0)