JavaScript Array Sort Method Tutorial

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.

Take Your Free Live Demo Class Now

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Send You the Course Fees Details In Below Number

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

Enter Your DETAILS BELOW TO take

free demo class