Syntax is as below:
compareFunction: Specifies a function that defines the sort order. The array is sorted lexicographically if this function is skipped
The lexicographic or lexicographical order is a generalization of alphabetical order of words based on the alphabetical order of their component letters.
Returns a sorted array.
var sortArray = myArr.sort();
document.write("<br />Sorted Array: " + sortArray);
Output: This will give the following output:
You can Try sort() method yourself here.