자바스크립트 객체 배열 정렬

개요[ | ]

자바스크립트 객체 배열 정렬
const objs = [
    {english: 50, math: 40},
    {english: 30, math: 60},
    {english: 90, math: 30},
    {english: 10, math: 20},
];
console.log( objs.sort((a,b) => a.english > b.english ? -1: 1) )
const objs = [
    {fruit: "lemon", owner: "Carol"},
    {fruit: "banana", owner: "Dave"},
    {fruit: "orange", owner: "Bob"},
    {fruit: "apple", owner: "Alice"},
];
console.log( objs.sort((a,b) => a.fruit < b.fruit ? -1: 1) )
const objs = [
    {fruit: "banana", owner: "Carol"},
    {fruit: "banana", owner: "Dave"},
    {fruit: "apple", owner: "Bob"},
    {fruit: "banana", owner: "Alice"},
];
console.log( objs.sort((a,b) => a.fruit+a.owner < b.fruit+b.owner ? -1: 1) )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}