我正在尝试按值排序我的JSON数组。在下面的示例中,第一项是"503": "07:25"
。 07:25
是我希望通过字母数字排序的行。
"333": [
{
"503": "07:25",
"507": "06:00",
"500x": "06:50",
"500x": "07:20",
"500": "07:35",
"503": "07:50",
"507": "07:40",
"500x": "07:55",
"500": "08:30",
"500x": "08:00",
"500": "10:45",
"507": "09:05",
"500": "10:45",
"507": "09:05",
"500": "13:45",
"500": "16:45",
"500": "20:00",
"500": "22:00",
"500N\n*Thur/Fri Only": "23:00"
},
{
"500": "12:00",
"500": "17:00",
"500": "21:30",
"500N": "00:45"
},
{
"500": "18:45"
}
],
"334": [{
"503": "07:26",
"507": "06:01",
"500x": "06:51",
"500x": "07:21",
"500": "07:36",
"503": "07:51",
"507": "07:41",
"500x": "07:56",
"500": "08:31",
"500x": "08:01",
"500": "10:46",
"507": "09:06",
"500": "13:46",
"500": "16:46",
"500": "20:01",
"500": "22:01",
"500N\n*Thur/Fri Only": "23:01"
},
{
"500": "12:01",
"500": "17:01",
"500": "21:31",
"500N": "00:46"
},
{
"500": "18:46"
}
],
}
我想要实现的是按值排序每个数组,使其看起来像这样
"333": [
{
"507": "06:00",
"500x": "07:20",
"503": "07:25",
"500x": "06:50",
...
无论如何,我可以遍历整个文件并输出按值排序的数组。我一直试图在javascript中实现这一点,但没有运气。