Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dictionary sort python

d={
  3: 4,
  1: 1,
  0: 0,
  4: 3,
  2: 1
}
y=dict(sorted(d.items(), key=lambda item: item[1]))
print(y) # {0: 0, 2: 1, 1: 2, 4: 3, 3: 4}
 
PREVIOUS NEXT
Tagged: #dictionary #sort #python
ADD COMMENT
Topic
Name
9+1 =