I have a dictionary:
dct = {'a' : [1,2] , 'b' : [5,9] , 'c' : [3,8] , 'd' : [0,1]}
I want to sort it by the first element in the value to get:
dct = {'d': [0, 1], 'a': [1, 2], 'c': [3, 8], 'b': [5, 9]}
Is this possible?
I have a dictionary:
dct = {'a' : [1,2] , 'b' : [5,9] , 'c' : [3,8] , 'd' : [0,1]}
I want to sort it by the first element in the value to get:
dct = {'d': [0, 1], 'a': [1, 2], 'c': [3, 8], 'b': [5, 9]}
Is this possible?
Copyright © 2021 Jogjafile Inc.
You can use
sorted()on the key and the value ofdict