Logo

Programming-Idioms

History of Idiom 100 > diff from v54 to v55

Edit summary for version 55 by programming-idioms.org:
[JS] +comment

Version 54

2019-10-14, 12:28:02

Version 55

2019-12-02, 16:59:06

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Extra Keywords
list
Extra Keywords
list
Code
items.sort(c);
Code
items.sort(c);
Comments bubble
c(a, b) returns a number to represent "a lesser than b", "a equals b", or "a greater than b".
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Demo URL
http://codepen.io/anon/pen/RoYPzy?editors=1111
Demo URL
http://codepen.io/anon/pen/RoYPzy?editors=1111