📌  相关文章
📜  对对象数组进行排序 javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:41.656000             🧑  作者: Mango

代码示例6
const books = [
  {id: 1, name: 'The Lord of the Rings'},
  {id: 2, name: 'A Tale of Two Cities'},
  {id: 3, name: 'Don Quixote'},
  {id: 4, name: 'The Hobbit'}
]

books.sort((a, b) => a.name.localeCompare(b.name))