I want to sort below array based on groupId
such that keys with smaller groupId
come first in array.
[
{
"groupId": 11,
"lowerThreshold": 33,
"target": {
"alarm_id": 22
},
"thresholdPeriod": 3,
"upperThreshold": 44
},
{
"groupId": 31,
"lowerThreshold": 33,
"target": {
"alarm_id": 122
},
"thresholdPeriod": 3,
"upperThreshold": 44
},
{
"groupId": "0",
"target": {
"alarm_id": "69"
},
"upperThreshold": "20",
"lowerThreshold": "10",
"thresholdPeriod": "5"
}
]
Expectation is
[
{
"groupId": "0",
"target": {
"alarm_id": "69"
},
"upperThreshold": "20",
"lowerThreshold": "10",
"thresholdPeriod": "5"
},
{
"groupId": 11,
"lowerThreshold": 33,
"target": {
"alarm_id": 22
},
"thresholdPeriod": 3,
"upperThreshold": 44
},
{
"groupId": 31,
"lowerThreshold": 33,
"target": {
"alarm_id": 122
},
"thresholdPeriod": 3,
"upperThreshold": 44
}
]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…