📅  最后修改于: 2022-03-11 15:01:55.807000             🧑  作者: Mango
const list = [
{ color: 'white', size: 'XXL' },
{ color: 'red', size: 'XL' },
{ color: 'black', size: 'M' }
]
var sortedArray = list.sort((a, b) => (a.color > b.color) ? 1 : -1)
// Result:
//sortedArray:
//{ color: 'black', size: 'M' }
//{ color: 'red', size: 'XL' }
//{ color: 'white', size: 'XXL' }