I have a JSON string that I want to sort. I want to sort it by the 'Name'
field. I can't for the life of me find code that does this.
Unsorted:
{"RU": {"Name": "Russian", "TextDirection": "ltr"}, "FR": {"Name": "French", "TextDirection": "ltr"}, "AR": {"Name": "Arabic", "TextDirection": "rtl"}}
Sorted:
{"AR": {"Name": "Arabic", "TextDirection": "rtl"}, "FR": {"Name": "French", "TextDirection": "ltr"}, "RU": {"Name": "Russian", "TextDirection": "ltr"}}
Update:
As @jonrsharpe and @martineau pointed out. I needed to use an array or a list. I'm not too concerned about the structure. What was originally messing up the sort order was the conversion to json. By using an array instead, json did not muck with the sort order.
[{"Code": "AR", "Name": "Arabic", "TextDirection": "rtl"}, {"Code": "FR", "Name": "French", "TextDirection": "ltr"}, {"Code": "RU", "Name": "Russian", "TextDirection": "ltr"}]