Sorting Algorithms Last Updated : 24 Aug, 2025 Comments Improve Suggest changes Like Article Like Report A Sorting Algorithm is used to rearrange a given array or list of elements in an order. For example, a given array [10, 20, 5, 2] becomes [2, 5, 10, 20] after sorting in increasing order and becomes [20, 10, 5, 2] after sorting in decreasing order. There exist different sorting algorithms for different different types of inputs, for example a binary array, a character array, an array with a large range of values or an array with many duplicates or a small vs large array.The algorithms may also differ according to output requirements. For example, stable sorting (or maintains original order of equal elements) or not stable. Sorting is provided in library implementation of most of the programming languages. These sorting functions typically are general purpose functions with flexibility of providing the expected sorting order (increasing or decreasing or by a specific key in case of objects).Basics Introduction to Sorting Applications of Sorting Sorting Algorithms:Comparison Based : Selection Sort, Bubble Sort, Insertion Sort, Merge Sort, Quick Sort, Heap Sort, Cycle Sort, 3-way Merge SortNon Comparison Based : Counting Sort, Radix Sort, Bucket Sort, TimSort, Comb Sort, Pigeonhole SortHybrid Sorting Algorithms : IntroSort, Tim SortLibrary Implementations:qsort() in Csort() in C++ STLArrays.sort() in Java with examplesCollections.sort() in Java with ExamplesSort a List in PythonSorting in JavaScriptEasy ProblemsCheck if an array is SortedSort an array of two typesSort a String Sort a MatrixSort a Linked ListSort in Wave Form Sort from Different MachinesCheck if any two intervals overlapMissing elements of a rangeSort by set bits countsSort even and odd placed in different orders Sort strings by lengthsMerge Two Sorted ArraysSort when two halves are sorted2 Sum - Pair in a Sorted ArrayIntersection & Union of two SortedMeeting RoomsK-th smallest after removing given SetMedium Problems Sort by Frequency Minimum Increments to Make Unique Merge Overlapping Intervals Maximum intervals overlap Minimum Platforms Chocolate Distribution ProblemMin and Max Amount to Buy AllThree Way PartitioningSort an array of 0s, 1s and 2sSort a linked list of 0s, 1s and 2s Inversion count K-th Smallest ElementK Smallest Elements3 Sum - Find Any3 Sum - Closest TripletSmallest Difference Triplet from Three arraysMerge K Sorted Arrays Min Unsorted Subarray to make array sortedSort a nearly sorted arraySort n numbers in range from 0 to n^2 – 1 Sort an array of 1 to nSort according to order defined by anotherPermute two arrays such that all pair suns are greater than K 4 Sum - Find Any [More problems an 4 Sum are in Hard Section]Hard ProblemsMerge Without Extra SpaceTop K Frequent Elements3 Sum - Distinct Triplets 4 Sum - Distinct Quadruples 4 Sum - All Quadruples4 Sum - Closest QuadrupleSurpasser Counts in an Array Minimum consecutive number subsets Min swaps to reach given array Making Array Elements SameSort after applying an equation Closest Pair of Points Quick Links :‘Practice Problems’ on Sorting Top Sorting Interview Questions‘Quizzes’ on Sorting Learn Data Structure and Algorithms | DSA Tutorial Overview of Sorting Algorithms Visit Course Overview of Sorting Algorithms Stability in Sorting Algorithm Comment More infoAdvertise with us H harendrakumar123 Follow Improve Article Tags : Sorting DSA Practice Tags : Sorting Explore Basics & PrerequisitesLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 4 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 14 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 6 min read Problem of The Day - Develop the Habit of Coding 5 min read Like