📅  最后修改于: 2022-03-11 15:01:41.656000             🧑  作者: Mango
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))