JavaScript Array sort()

The JavaScript array sort() method is used to return the element of the given array in a sorted order. Syntax: array.sort(compareFunction) Parameters: compareFunction: It represents a function that provides the functionality of sort order. It is an optional parameter. Returns: An array with sorted elements. Example: <!DOCTYPE html> <html> <body> <script> var a = [“GOLD”,”SILVER”,”DIAMOND”,”RUBY”,”PLATINUM”] … Read more