arr.sort(fn)

Let arr = [ 1, 2, 15 ];

// the method reorders the content of arr (and returns it)
arr.sort();

alert( arr );  // *!*1, 15, 2*/!*
Let arr = [ 1, 2, 15 ];
arr.sort(function(a, b) { return a - b; });
alert(arr);  // *!*1, 2, 15*/!*

The method arr.sort sorts the array in place.

The arr.sort(fn) method has a built-in implementation of sorting algorithm.

Related concepts

arr.sort(fn)

arr.sort(fn) — Structure map

Clickable & Draggable!

arr.sort(fn) — Related pages: