sort method is used to sort the elements of array in term of their occurrences.
//Name of the file : array-sort.js
arr = ['b','e','a','o','p','n','r'];
console.log(arr);
arr.sort();
console.log(arr);
>node array-sort.js
[ 'b', 'e', 'a', 'o', 'p', 'n', 'r' ]
[ 'a', 'b', 'e', 'n', 'o', 'p', 'r' ]