Possible duplicate:
Sort JavaScript object by property value
Since I noticed that the browser cannot guarantee JSON order through an ajax call ( link ), I am having some problems sorting the JSON element with javascript after the ajax call.
I found several topics about this problem, but nothing gave me a clear solution for the simple structure of my JSON object. I have only 1 segment with a lot of data. I know there are a lot of topics about this, even on stackoverflow, but not a single topic handles this simple json structure.
For instance:
{ "158":"Banana", "265":"Pear", "358":"Apple", "864":"Peach" }
How can I sort this object by fruit name, not id? I would like to have this object at the end:
{ "358":"Apple", "158":"Banana", "864":"Peach" "265":"Pear", }
Thanks in advance.
source share