I have the following data:
{
"Flat": {
"id": 40,
"created_at": "2021-07-12 17:04:12",
"updated_at": "2021-07-12 17:04:12",
"product_type": "Plate Hats",
"product_tag": "Plate Hat Production",
"layout": "plate template.ai",
"dept": "UV",
"setup": "multi-flat"
},
"Washington City": {
"productTemplate": {
"id": 914,
"created_at": "2019-03-26 16:58:23",
"updated_at": "2019-03-26 16:58:23",
"name": "Washington City",
"template": "prt_Washington.ai",
"fonts": "1",
"custom_text": "2",
"r": "34",
"g": "42",
"b": "86",
"top": "41",
"spacing": "89",
"relationId": null,
"aWidth": null,
"aHeight": null,
"productGroup": "40",
"shopifyId": "169405808664"
},
"colorVariants": false
},
"Kansas City": {
"productTemplate": {
"id": 915,
"created_at": "2019-03-26 16:58:23",
"updated_at": "2019-03-26 16:58:23",
"name": "Kansas City",
"template": "prt_Washington-DC.ai",
"fonts": "1",
"custom_text": "2",
"r": "42",
"g": "78",
"b": "157",
"top": "49",
"spacing": "75",
"relationId": null,
"aWidth": null,
"aHeight": null,
"productGroup": "40",
"shopifyId": "1308169306180"
},
"colorVariants": false
},
...
I would like to sort this based on the field "Flat", "Washington City", etc. The issue is these are dynamic and there's about 300 of them. I've seen several answers suggesting using usort but there is always a field that is identified in example "id" in this data.
Here is an example of doing it with "title" as the field. But again here I don't kno
usort($your_array, function ($elem1, $elem2) {
return strcmp($elem1['title'], $elem2['title']);
});
Any idea how I can accomplish this?