Sorting algorithms arrange the elements in a collection in ascending or descending order. Lexicographical order can be applied to a collection of characters and strings. The efficiency of these algorithms is in the performance of sorting the input data into a sorted collection. The best sorting algorithm time complexity is O(n log n). Sorting algorithms are classified by the following criteria:
- Computational complexity
- Memory usage
- Stability
- Type of sorting: serial/parallel
- Adaptability
- Method of sorting
In the following sections, we'll look at the different sorting algorithms, that is, bubble, selection, insertion, shell, merge, and quick.