JavaScript array.sort() Function

JavaScript Logo

array.sort() – Sorts the elements of an array **in place** and returns the sorted array.

๐Ÿ‘‰ Syntax

array.sort(compareFunction);

๐Ÿงช Example

[3,1,2].sort(); // [1,2,3]

Comments