var
json=
{s:[{id:s2,
ss:[
{id:‘s2ss1‘,"字段A":‘efg‘,"字段B":‘123‘},
{id:‘s2ss2‘,"字段A":‘efg‘,"字段B":‘123‘}
]
},{
id:‘s1‘,
ss:[
{id:‘s1ss2‘,"字段A":‘efg‘,"字段B":‘123‘},
{id:‘s1ss1‘,"字段A":‘efg‘,"字段B":‘123‘},
]
}]}
排序方式如下:
json[
"s"
].sort(
function
(a,b){
return
a[
"id"
]>b[
"id"
]?1:-1})