Skip to content

Instantly share code, notes, and snippets.

@marcoshipe
Created September 28, 2018 15:09
Show Gist options
  • Select an option

  • Save marcoshipe/3a1a62bbe0262ce511b5f7443322227d to your computer and use it in GitHub Desktop.

Select an option

Save marcoshipe/3a1a62bbe0262ce511b5f7443322227d to your computer and use it in GitHub Desktop.
OrderedDict-ProblemaPyarTelegram
from collections import OrderedDict
custom_dict = {
'props_videos': {
1: {
'obj': 'a',
'nombre': 1
},
2: {
'obj': 'c',
'nombre': 2
},
3: {
'obj': 'b',
'nombre': 3
},
}
}
props_videos = OrderedDict()
for objeto in sorted(custom_dict['props_videos'].values(), key=lambda x: x['obj']):
props_videos[objeto['obj']] = objeto
print(props_videos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment