Overview
A sorting algorithm is an algorithm that puts elements of a list in
a certain order (thus sorting the list). The most frequently used
orders are numerical order for lists of numbers and lexicographical
order for lists of strings.
To put it more formally, the output generally has to fulfill two
conditions:
- The output is in nondecreasing order
- The output is a permutation of the input
Or, to put it simply, when running a sorting algorithm we expect an
output that contains all the elements originally present in the
input arranged in such a way that the smallest element (according to
the operation used to sort the list) is in the leftmost place, with
every element following being either bigger or equal to its
predecessor.
Sorting algorithms can generally be classified into three distinct
categories:
- Comparison sorts
- Non-comparison sorts
- Others
On this page, you can find many implementations for every category. If you need a visualization for a certain algorithm, just use the search function to find it quickly.
Search
Comparison Sorts
A comparison sort is a type of sorting algorithm that only reads the list elements through a single abstract comparison operation that determines which of two elements should occur first in the final sorted list.
Non-Comparison Sorts
Non-Comparison Sorts are sorting algorithms that sort a given input without comparing the elements, instead making certain assumptions about the data. Examples include Counting Sort, which sorts using key-value, and Bucket Sort, which examines bits of keys.
Others
Algorithms in this category are impractical for real-life use in traditional software contexts due to extremely poor performance or specialized hardware requirements. These sorts are usually described for educational purposes to demonstrate how the runtime of algorithms is estimated.