📌  相关文章
📜  js 对数组进行排序 - Javascript 代码示例

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

代码示例6
// sort an array
// by drinks: lowest to highest
function sortDrinkByPrice(drinks) {
    return drinks.sort((a, b) => {
        return a.price - b.price;
    });
}

// parse the array as parameters within the function
console.log(sortDrinkByPrice([{name: "lemonade", price: 50},{name: "lime", price: 10}]));