Stars on GitHub
Different sorting algorithms
in more than
different programming languages
Quick Sort is a highly efficient divide-and-conquer sorting algorithm. It works by selecting a 'pivot' element and partitioning the array into elements less than the pivot and elements greater than the pivot, then recursively sorting the partitions.
Merge Sort is a divide-and-conquer sorting algorithm that divides the array into halves, recursively sorts them, and then merges the sorted halves into a single sorted array.
Pattern Defeating Quick Sort (PDQSort) is an advanced variant of Quick Sort that detects patterns in the input data to reduce unnecessary work and improve performance on partially sorted arrays.
Introsort (Introspective Sort) is a hybrid sorting algorithm that begins with Quick Sort and switches to Heap Sort when the recursion depth exceeds a certain limit, guaranteeing O(n log n) worst-case performance while retaining excellent average-case behavior.
Pattern-Defeating Quicksort (pdqsort) is an advanced hybrid sorting algorithm based on Quicksort that detects and defeats input patterns which would cause bad performance. It combines adaptive partitioning, branchless comparisons, and a fallback to Heapsort to guarantee O(n log n) worst-case complexity. It is used in modern standard libraries such as C++ std::sort implementations.
Binary Insertion Sort is a variation of Insertion Sort that uses binary search to find the correct position to insert the current element, reducing the number of comparisons but still requiring shifting of elements.
Heap Sort is a comparison-based sorting algorithm that builds a binary heap from the input array and repeatedly extracts the maximum element to produce a sorted array.
Radix Sort (Least Significant Digit) sorts numbers by processing individual digits from least significant to most significant using a stable sort at each digit level.
Radix Sort (Most Significant Digit) sorts numbers by processing digits from the most significant to the least significant using recursive bucket sorting.
Counting Sort is a non-comparison-based sorting algorithm that counts the occurrences of each element and calculates their positions in the sorted array.
Dual Pivot Quick Sort uses two pivots to partition the array into three parts, improving performance compared to classic Quick Sort in many practical scenarios.
Proportion Extend Quick Sort is a variant of Quick Sort that uses a proportional pivot selection strategy to reduce the likelihood of worst-case performance.
Iterative Merge Sort sorts an array using a bottom-up approach, merging subarrays iteratively rather than using recursion.
Quad Merge Sort is a divide-and-conquer sorting algorithm that recursively splits the array into four parts, sorts them individually, and merges them efficiently.
Block Sort, also known as Block Merge Sort, is an in-place, stable sorting algorithm that divides the array into blocks and merges them efficiently using a combination of internal and external buffers.
Smooth Sort is a comparison-based in-place sorting algorithm developed by Edsger Dijkstra. It is a variation of Heap Sort that adapts to partially sorted data to achieve near-linear time for sorted inputs.
In Place Radix LSD (Least Significant Digit) is a non-comparative, stable sorting algorithm that sorts integers by processing digits from least to most significant, all done in-place to reduce memory usage.
In Place Radix MSD (Most Significant Digit) is a non-comparative, in-place, stable sorting algorithm that sorts integers by processing digits from most to least significant.
Binary Quick Sort is a variant of Quick Sort that partitions the array based on a binary bit at a specific position, efficiently sorting integers in-place using bitwise comparisons.
American Flag Sort is an in-place, stable, radix-based sorting algorithm that improves on LSD/MSD radix sorts by grouping elements into buckets based on digit positions and redistributing them efficiently.
Spread Sort is a comparison-based sorting algorithm optimized for uniformly distributed numbers. It divides the range of input values into bins, recursively sorts bins, and merges them efficiently.
Sample Sort is a divide-and-conquer sorting algorithm that selects a sample of elements to determine splitters for partitioning the array, recursively sorting each partition for efficient parallel or sequential sorting.
Wiki Sort is a stable, in-place merge sort variant designed for practical efficiency, combining block merging and smart rotations to reduce memory usage and comparisons.
Grail Sort is a stable, in-place merge sort variant that uses small internal buffers to reduce memory overhead while achieving efficient merges. It is designed for practical performance on modern systems.
Fluxsort is a modern hybrid comparison-based sorting algorithm designed as an improvement over Quicksort. It uses adaptive partitioning and cache-friendly techniques to achieve excellent real-world performance while maintaining O(n log n) worst-case complexity.
Double Selection Sort is an optimized variation of Selection Sort that finds both the minimum and maximum elements in the unsorted region in each pass and places them at the beginning and end of the sorted region, respectively.
Insertion Sort is a simple sorting algorithm that builds the sorted array one element at a time by repeatedly taking the next element and inserting it into its correct position in the already sorted portion.
Comb Sort is an improvement over Bubble Sort that eliminates turtles (small values near the end) by using a gap sequence to compare and swap elements further apart.
Shell Sort is an in-place comparison-based sorting algorithm that generalizes insertion sort by allowing the exchange of items far apart. It uses a gap sequence to sort elements at specific intervals.
Bucket Sort distributes elements into a number of buckets, sorts each bucket individually (often using another sort), and then concatenates them to get a sorted array.
Cycle Sort is an in-place, unstable sorting algorithm that minimizes the number of writes by rotating elements to their correct positions in cycles.
Patience Sort builds piles of cards and then merges them to produce a sorted sequence. It is inspired by the card game 'Patience' and is useful for finding the Longest Increasing Subsequence efficiently.
Merge-Insertion Sort is a hybrid sorting algorithm that combines the efficiency of Merge Sort with the simplicity of Insertion Sort for small subarrays to optimize performance.
Tournament Sort builds a tournament tree to repeatedly select the minimum (or maximum) element, making it an efficient way to sort when merging multiple streams of data.
Tree Sort builds a Binary Search Tree (BST) from the elements and performs an in-order traversal to retrieve the elements in sorted order.
Library Sort is a variant of insertion sort that leaves gaps between elements to speed up insertions, making it faster than standard insertion sort for large datasets.
Topological Sort orders the vertices of a directed acyclic graph (DAG) such that for every directed edge u → v, u comes before v in the ordering.
Quick LL Sort is Quick Sort adapted for linked lists. It partitions the list and recursively sorts the partitions, efficiently handling pointer-based structures.
In Place Merge Sort is a variant of Merge Sort that merges sorted subarrays without requiring additional memory, achieving O(1) extra space at the cost of more complex element shifting.
Weave Merge Sort is an in-place merge sort variant that interleaves elements from two sorted subarrays by weaving them together, reducing memory usage while maintaining stability.
Rotate Merge Sort is an in-place merge algorithm that rotates elements to merge two consecutive sorted subarrays efficiently without additional memory.
Weak Heap Sort is a comparison-based in-place sorting algorithm that builds a weak heap, a variant of a binary heap, and repeatedly extracts the maximum element.
Poplar Sort is a comparison-based, in-place sorting algorithm that builds a poplar tree (a type of multiway heap) and repeatedly extracts the maximum element.
Ternary Heap Sort is a variation of Heap Sort where each parent node has three children instead of two. It maintains a ternary max-heap and repeatedly extracts the maximum element.
Burst Sort is a string-sorting algorithm that organizes data into buckets based on character prefixes, then recursively sorts each bucket, optimizing for large datasets with many common prefixes.
Proxmap Sort is a distribution-based sorting algorithm that maps keys to positions in an array (proximity map) and inserts them directly into their approximate final positions, reducing comparisons and improving performance for uniformly distributed data.
Cartesian Tree Sort builds a Cartesian Tree from the input array, maintaining the heap property while preserving the in-order sequence, then performs an in-order traversal to produce a sorted array.
Sqrt Sort is a hybrid sorting algorithm that divides the array into √n blocks, sorts each block individually, and then merges them efficiently.
Power Sort is a hybrid sorting algorithm inspired by natural merge sort and smoothsort principles. It adapts dynamically to partially sorted sequences to achieve efficient sorting in practice.
Franceschini's Method is a hybrid sorting algorithm that combines bucket classification with a final local insertion sort. It partitions elements into ordered sequences based on value ranges, redistributes them efficiently, and completes the sort with localized comparisons. It performs well on partially ordered or moderately distributed data.
Flash Sort is a distribution-based sorting algorithm that works by classifying elements into buckets (classes) based on a linear transformation, then permuting elements into their correct classes before finishing with a local sort. It is efficient for uniformly distributed data.
Selection Sort is a simple comparison-based sorting algorithm that divides the input list into a sorted and an unsorted region. It repeatedly selects the smallest (or largest) element from the unsorted region and moves it to the end of the sorted region.
Bubble Sort is a simple comparison-based sorting algorithm where each pair of adjacent elements is compared and swapped if they are in the wrong order. This process is repeated until the list is sorted.
Shaker Sort, also called Cocktail Sort, is a bidirectional variation of Bubble Sort that passes through the list in both directions alternatively to bubble up the largest and smallest elements.
Pancake Sort repeatedly flips the largest unsorted element to the top and then to its correct position, similar to flipping pancakes in a stack.
Exchange Sort is a simple comparison-based sorting algorithm that compares each pair of elements and swaps them if they are in the wrong order.
Odd-Even Sort is a parallel-friendly sorting algorithm that repeatedly compares and swaps adjacent elements in alternating odd and even phases until the array is sorted.
Circle Sort is a recursive comparison-based sorting algorithm that compares elements in a mirrored fashion (first with last, second with second-last, etc.) and swaps them if needed until the array is sorted.
Strand Sort is a recursive sorting algorithm that repeatedly extracts increasing subsequences (strands) from the input list and merges them into a sorted list.
Bitonic Sort is a parallel sorting algorithm that works by constructing bitonic sequences and then merging them into a sorted sequence. Efficient for hardware and parallel execution.
Odd-Even Network Sort is a comparison-based network sorting algorithm that repeatedly compares and swaps odd-even indexed pairs of elements, suitable for parallel hardware implementation.
Pairwise Network Sort compares and swaps pairs of elements in a structured sequence, forming a sorting network suitable for parallel execution.
Cube Sort is a parallel-friendly sorting algorithm that generalizes comparison-based sorting by arranging elements into a multidimensional cube structure, sorting along each dimension iteratively. It is mainly of theoretical and educational interest.
Pigeonhole Sort is a non-comparison sorting algorithm suitable when the number of elements and the range of possible key values are approximately the same. It works by placing elements into 'holes' corresponding to their key values and then collecting them in order.
Postman Sort is a specialized distribution-based sorting algorithm inspired by postal service workflows. It is a variation of Bucket Sort and works very similarly to MSD Radix Sort, grouping elements by progressively more specific key digits. It is mainly of theoretical and historical interest.
Spaghetti Sort is a sorting algorithm that uses the analogy of spaghetti sticks of varying lengths: the tallest 'stick' is repeatedly removed to produce a sorted sequence.
Gravity Sort, also known as Bead Sort, simulates beads falling on parallel rods; the beads slide down to sort numbers naturally based on gravity.
Bogo Sort randomly shuffles the array until it happens to be sorted. It is extremely inefficient and mostly used for educational or humorous purposes.
Gnome Sort is a simple comparison-based sorting algorithm that moves elements to their correct position by swapping them with the previous element, similar to insertion sort but using a series of swaps.
Stooge Sort is a recursive comparison-based sorting algorithm. It swaps elements if the first is greater than the last, then recursively sorts the first two-thirds, last two-thirds, and first two-thirds again. It's mostly of academic interest due to its poor performance.
Slow Sort is a deliberately inefficient, recursive sorting algorithm that works by recursively sorting all but the last element, then sorting all but the first element, and finally swapping the first and last elements if needed. It's mostly for academic or illustrative purposes.
Stalin Sort is a satirical sorting algorithm that removes any element that is out of order rather than swapping it. The remaining elements are sorted by default. It's mostly a humorous example of a destructive sort.
Sleep Sort is a humorous, timing-based sorting algorithm that starts a separate thread or timeout for each element, sleeping for a duration proportional to the element's value and then outputting it. It's mostly for demonstration and entertainment.
Bogobogo Sort is a humorous, extremely inefficient recursive version of Bogo Sort that repeatedly shuffles subarrays until they are sorted. It is mostly a theoretical and comedic example of a 'bad' sorting algorithm.
Linear Sort is a tongue-in-cheek theoretical algorithm that achieves apparent linear time by delegating the actual sorting work to an efficient algorithm (typically Merge Sort) and then artificially delaying completion to simulate linear complexity. It is not practical and exists mainly as a joke or thought experiment.