Logo

Programming-Idioms

History of Idiom 100 > diff from v9 to v10

Edit summary for version 10 by :
New JS implementation by user [benaryorg]

Version 9

2015-12-27, 16:39:17

Version 10

2015-12-27, 16:44:27

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.

Code
var lst = [7,4,3,1,2];

lst.sort(function(a,b){return a-b;});

console.log(lst);