let data = [
{
key:10,
value:"第10"
},
{
key:16,
value:"第16"
},
{
key:12,
value:"第12"
},
{
key:30,
value:"第30"
},
{
key:2,
value:"第2"
}
]
data.sort(function(a, b){return b.key - a.key})
console.log(data)
结果: