fork(1) download
  1. from collections import OrderedDict
  2.  
  3. dicionario = {
  4. (0,0,0): ['0, 0, 0'],
  5. (0,0,1): ['0, 0, 1'],
  6. (0,0,2): ['0, 0, 2'],
  7. (0,0,5): ['0, 0, 5'],
  8. (0,1,0): ['0, 1, 0']
  9. }
  10.  
  11. novo_dicionario = OrderedDict(sorted(dicionario.items(), key=lambda item: item[0][2]))
  12.  
  13. for key, value in novo_dicionario.items():
  14. print(key, value)
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
(0, 1, 0) ['0, 1, 0']
(0, 0, 0) ['0, 0, 0']
(0, 0, 1) ['0, 0, 1']
(0, 0, 2) ['0, 0, 2']
(0, 0, 5) ['0, 0, 5']