0

Jquery Object

{"2":"text1", "5":"text2", "3":"text3"}

I need to reverse it like -

{"3":"text3", "5":"text2", "2": "text1"}

What is the optimal way to achieve this?

SandyK
  • 465
  • 1
  • 9
  • 28
  • Why do you need to do this? While the order of properties in an object can potentially be amended, a far better and more reliable solution would be to use an array of objects, `[{"2":"text1" }, { "5":"text2" }, { "3":"text3" }]` which you can then `reverse()` or `sort()` as required. – Rory McCrossan Dec 07 '21 at 13:00
  • You will find your answer : https://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order – infomasud Dec 08 '21 at 15:58

0 Answers0