In computer science, a sorting algorithm is an algorithm that puts elements of a list into an order. The most frequently used orders are numerical order and lexicographical order, and either ascending or descending. Efficient sorting is important for optimizing the efficiency of other algorithms (such as search and merge algorithms) that require input data to be in sorted lists. Sorting is also often useful for canonicalizing data and for producing human-readable output.
Formally, the output of any sorting algorithm must satisfy two conditions:
The output is in monotonic order (each element is no smaller/larger than the previous element, according to the required order).
The output is a permutation (a reordering, yet retaining all of the original elements) of the input.
For optimum efficiency, the input data should be stored in a data structure which allows random access rather than one that allows only sequential access.
lists. Sorting is also often useful for canonicalizing data and for producing human-readable output. Formally, the output of any sortingalgorithm must...
Bubble sort, sometimes referred to as sinking sort, is a simple sortingalgorithm that repeatedly steps through the input list element by element, comparing...
set. Topological sorting is possible even when the DAG has disconnected components. The canonical application of topological sorting is in scheduling...
science, patience sorting is a sortingalgorithm inspired by, and named after, the card game patience. A variant of the algorithm efficiently computes...
computer science, merge sort (also commonly spelled as mergesort) is an efficient, general-purpose, and comparison-based sortingalgorithm. Most implementations...
Insertion sort is a simple sortingalgorithm that builds the final sorted array (or list) one item at a time by comparisons. It is much less efficient...
published in 1961. It is still a commonly used algorithm for sorting. Overall, it is slightly faster than merge sort and heapsort for randomized data, particularly...
computer science, bogosort (also known as permutation sort and stupid sort) is a sortingalgorithm based on the generate and test paradigm. The function...
identifiers of the classes may be members of an ordered set, allowing a sortingalgorithm to arrange the items by class. Formally speaking, a collation method...
shaker sort is used primarily as an educational tool. More performant algorithms such as quicksort, merge sort, or timsort are used by the sorting libraries...
In computer science, selection sort is an in-place comparison sortingalgorithm. It has an O(n2) time complexity, which makes it inefficient on large lists...
an ordered sequence is called "sorting". Sorting is a common operation in many applications, and efficient algorithms have been developed to perform it...
In computer science, radix sort is a non-comparative sortingalgorithm. It avoids comparison by creating and distributing elements into buckets according...
flag sort is an efficient, in-place variant of radix sort that distributes items into buckets. Non-comparative sortingalgorithms such as radix sort and...
Timsort is a hybrid, stable sortingalgorithm, derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data....
counting sort is an algorithm for sorting a collection of objects according to keys that are small positive integers; that is, it is an integer sorting algorithm...
External sorting is a class of sortingalgorithms that can handle massive amounts of data. External sorting is required when the data being sorted do not...
comparison-based sortingalgorithm which can be thought of as "an implementation of selection sort using the right data structure." Like selection sort, heapsort...
Pancake sorting is the mathematical problem of sorting a disordered stack of pancakes in order of size when a spatula can be inserted at any point in the...
Bucket sort, or bin sort, is a sortingalgorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually...
as smaller than "11". Alphabetical sorting: z11 z2 Natural sorting: z2 z11 Functionality to sort by natural sort order is now widely available in software...
lists in sorted order. These algorithms are used as subroutines in various sortingalgorithms, most famously merge sort. The merge algorithm plays a critical...
Comb sort is a relatively simple sortingalgorithm originally designed by Włodzimierz Dobosiewicz and Artur Borowy in 1980, later rediscovered (and given...
Introsort or introspective sort is a hybrid sortingalgorithm that provides both fast average performance and (asymptotically) optimal worst-case performance...