0

I only want to do a very simple think, not reverse the key to value but only reverse the order of dictionary from

{'a':1, 'f':3: 'd':2}

to this

{'d':2, 'f':3: 'a':1}

I don't need key value switching like some many solution out there.. Yes it's doesn't mean anything in the functionality but i just need that for "eye catching" json structure.

Is there any way to do that?

Faizalprbw
  • 529
  • 1
  • 6
  • 17
  • Not 100.00% a duplicate, but the point is that you're asking how to order a dictionary - which is explained in multiple questions elsewhere. Dictionaries can't be sorted by definition – TerryA Oct 27 '17 at 03:59
  • @TerryA I know what you mean, but the English meanings of the last sentence may make it confusing for a newer user or an ESL speaker, on account of how real-world dictionaries have definitions in the same way that Python dictionaries have values. – Holland Wilson Oct 27 '17 at 04:02
  • @TerryA, yes i just need something like list.reverse() in list.. – Faizalprbw Oct 27 '17 at 05:32
  • Something like https://stackoverflow.com/questions/483666/python-reverse-invert-a-mapping, https://stackoverflow.com/questions/35945473/how-to-reverse-a-dictionary-in-python, or this https://stackoverflow.com/questions/43436595/python-reverse-dictionary is not the answer – Faizalprbw Oct 27 '17 at 05:44

0 Answers0