Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

# sort the dictionary

# sort the dictionary
d3 = {'apple': 1, 'oranges': 2, 'bananas': 3, 'grapes': 4, 'strawberries': 5, 'watermelon': 6}
sort_arr= dict(sorted(d3.items(), reverse = True))
print(sort_arr)

# {'watermelon': 6, 'strawberries': 5, 'oranges': 2, 'grapes': 4, 'bananas': 3, 'apple': 1}
 
PREVIOUS NEXT
Tagged: #sort #dictionary
ADD COMMENT
Topic
Name
9+7 =