Sorting algorithm
A sorting algorithm is a way to put elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (like search and merge algorithms) which require input data to be in sorted lists. It is also often useful for canonicalizing data and for producing human-readable output.
The output must satisfy following two conditions:
- The output is in no decreasing order i.e.each element is no smaller than the previous element according to the desired total order.
- The output is a reordering of elements but with all of the original elements of the input.