如何在JavaScript中对对象的对象进行排序?

时间:2018-04-15 22:32:58

标签: javascript sorting object

我有一个名为teams的对象对象:

{
"1": {
    "number": "134C",
    "robotName": "chazzen",
    "name": "Team Discovery - Charlie",
    "organization": "Pembroke Academy",
    "city": "Pembroke",
    "region": "New Hampshire",
    "country": "United States"
},
"2": {
    "number": "134G",
    "robotName": "Ghammer Time",
    "name": "Team discovery -Golf",
    "organization": "Pembroke Academy",
    "city": "Pembroke",
    "region": "New Hampshire",
    "country": "United States"
},
"3": {
    "number": "134K",
    "robotName": "Team Discovery kilo",
    "name": "Team Discovery -Kilo",
    "organization": "Pembroke Academy",
    "city": "Pembroke",
    "region": "New Hampshire",
    "country": "United States"
},
"4": {
    "number": "134E",
    "robotName": "Team Discovery -Echo",
    "name": "Team Discovery - Echo",
    "organization": "Pembroke Academy",
    "city": "Pembroke",
    "region": "New Hampshire",
    "country": "United States"
}

}

如何对这些"子对象进行排序"按字母顺序和数字顺序排列,例如" number"或"名称"在一个函数?

0 个答案:

没有答案