There are very many sorting algorithms that work with varying degrees of efficiency. Some sorting methods require additional storage space besides that needed to store the array. The complexity and memory requirements of some sorting algorithms depend on the initial arrangement of the values in the array, and a distinction is then made between best case, average case and worst case.
Sorting methods can generally be distinguished by the basis of their operation into stable and non-stable sorting algorithms. Stable sorting algorithms are those that do not change the relative order of elements that are equivalent in terms of order, while unstable sorting algorithms do not guarantee this.