Possible Duplicate:
Sorting JavaScript Object by property value
Since I've noticed the browser can't guarantee the ordering of a JSON trough an ajax call (reference), I'm having some troubles with sorting the JSON element with javascript after the ajax call.
I've found some topics about this issue, but nothing gave me a clear solution for the simple structure of my JSON object. I just got 1 segment with a lot of data. I know there are a lot of topics about this, even on stackoverflow, but no topic handles this simple json structure.
For example:
{
"158":"Banana",
"265":"Pear",
"358":"Apple",
"864":"Peach"
}
How can I sort this object on the fruitnames instead of the id's? I'd like to have this object at the end:
{
"358":"Apple",
"158":"Banana",
"864":"Peach"
"265":"Pear",
}
Thanks in advance.