I have a dictionary like:
{'sortingOrder': ['da','ub','ac','rd'], 'listToSort': [{_id:'ub'}, {_id: 'da'}, {_id: 'rd'}, {_id: 'ac'}]}
I want to sort this list so that the id in listToSort matches how sortingOrder is sorted
[{_id:'da'}, {_id: 'ub'}, {_id: 'ac'}, {_id: 'rd'}]
I have to compare a value from listToSort with a value from sortingOrder and sort listToSort accordingly, which has been my main issue.
The id can be any type of character, it just needs to be sorted the same way sortingOrder is sorted.
Sample of the file I have to sort by section title:
{
"storeOrder": ["produce", "bread", "spreads", "deli", "dairy"],
"itemList": [
{
"_id": 9,
"amountNumber": 1,
"amountStr": "2 loaves",
"amountUnits": null,
"estPrice": null,
"listId": 3,
"modified": "2010-10-26 18:11:58",
"name": "white bread",
"notes": null,
"price": null,
"section": "bread",
"status": 1
},
{
"_id": 12,
"amountNumber": 1,
"amountStr": "1 jar",
"amountUnits": null,
"estPrice": null,
"listId": 3,
"modified": "2010-10-26 18:11:58",
"name": "raspberry jam",
"notes": "large bottle",
"price": null,
"section": "spreads",
"status": 0
}
}
itemListto share asectionvalue? In that case, is there a secondary sorting field (likenamefor example)?