Array Sort() Method
The Javascript array sort() method sorts the elements of an array.
Syntax
Its syntax is as follows?
array.sort( compareFunction );
Parameter Details
compareFunction? Specifies a function that defines the sort order. If omitted, the array is sorted lexicographically.
Return Value
Returns a sorted array.
Example
Try the following example.