The JavaScript Array. sort() method is used to sort the array elements in-place and returns the sorted array. This function sorts the elements in string format.The sort() method sorts the array elements in ascending order with the smallest value first and largest value last.