sorting algorithm

Sorting is a fundamental algorithm design problem. A sorting algorithm is an algorithm that puts elements in a numerical order or lexicographical order. 
Many efficient algorithms use sorting as a subroutine, because it is often easier to process data if the elements are in a sorted order. For example, the problem "does an array contain two equal elements?” is easy to solve using sorting. If the array contains two equal elements, they will be next
to each other after sorting, so it is easy to find them. Also, the problem "what is the most frequent element in an array?” can be solved similarly.