var votes = [ { title: 'Apple', votes: 1 }, { title: 'Milk', votes: 2 }, { title: 'Carrot', votes: 3 }, { title: 'Banana', votes: 2 } ]; votes.sort(function (vote1, vote2) { console.log(vote1); console.log(vote2); }); // Logs this to the console... // {title: "Apple", votes: 1} // {title: "Milk", votes: 2} // {title: "Milk", votes: 2} // {title: "Carrot", votes: 3} // {title: "Carrot", votes: 3} // {title: "Banana", votes: 2}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter