Sorting AlgorithmsLast Updated : 26 Jul, 2023ReadDiscussCoursesDSA for BeginnersLearn more about Sorting in DSA Self Paced CoursePractice Problems on SortingTop Quizzes on Sorting AlgorithmsWhat is Sorting?A Sorting Algorithm is used to rearrange a given array or list of elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of elements in the respective data structure.For Example: The below list of characters is sorted in increasing order of their ASCII values. That is, the character with a lesser ASCII value will be placed first than the character with a higher ASCII value.Sorting AlgorithmsSorting Algorithms:Selection SortBubble SortInsertion SortMerge SortQuick SortHeap SortCounting SortRadix SortBucket SortBingo Sort AlgorithmShellSortTimSortComb SortPigeonhole SortCycle SortCocktail SortStrand SortBitonic SortPancake sortingBogoSort or Permutation SortGnome SortSleep Sort – The King of LazinessStructure Sorting in C++Stooge SortTag Sort (To get both sorted and original)Tree SortOdd-Even Sort / Brick Sort3-way Merge SortTable of Complexity Comparison:NameBest Case Average Case Worst Case MemoryStable Method UsedQuick SortNoPartitioningMerge SortnYesMergingHeap Sort1NoSelectionInsertion Sortn1YesInsertionTim SortnnYesInsertion & MergingSelection Sort1NoSelectionShell Sort1NoInsertionBubble Sortn1YesExchangingTree SortnYesInsertionCycle Sort1NoSelectionStrand SortnnYesSelectionCocktail Shaker Sortn1YesExchangingComb Sort1NoExchangingGnome Sortn1YesExchangingOdd–even Sortn1YesExchangingLibrary Implementations:Introsort – C++’s Sorting WeaponComparator function of qsort() in Csort() in C++ STLC qsort() vs C++ sort()Arrays.sort() in Java with examplesCollections.sort() in Java with ExamplesSome standard problems on Sorting:Easy:Sort elements by frequencySort an array of 0s, 1s and 2sSort numbers stored on different machinesSort an array in wave formCheck if any two intervals overlap among a given set of intervalsHow to sort an array of dates in C/C++?Sorting Strings using Bubble SortFind missing elements of a rangeSort an array according to count of set bitsSort even-placed elements in increasing and odd-placed in decreasing orderSort an array when two halves are sortedSorting Big IntegersSort a linked list of 0s, 1s and 2sMedium:Inversion count in Array using Merge SortFind the Minimum length Unsorted Subarray, sorting which makes the complete array sortedSort a nearly sorted (or K sorted) arraySort n numbers in range from 0 to n^2 – 1 in linear timeSort an array according to the order defined by another arrayFind the point where maximum intervals overlapFind a permutation that causes worst case of Merge SortSort Vector of Pairs in ascending order in C++Minimum swaps to make two arrays identicalChocolate Distribution ProblemPermute two arrays such that sum of every pair is greater or equal to KBucket Sort To Sort an Array with Negative NumbersSort a Matrix in all way increasing orderConvert an Array to reduced form using Vector of pairsSmallest Difference Triplet from Three arraysCheck if it is possible to sort an array with conditional swapping of adjacent allowedHard:Find Surpasser Count of each element in arrayCount distinct occurrences as a subsequenceCount minimum number of subsets (or subsequences) with consecutive numbersChose k array elements such that difference of maximum and minimum is minimizedMinimum swap required to convert binary tree to binary search treeK-th smallest element after removing some integers from natural numbersMaximum difference between frequency of two elements such that element having greater frequency is also greaterMinimum swaps to reach permuted array with at most 2 positions left swaps allowedFind whether it is possible to make array elements same using one external numberSort an array after applying the given equationPrint array of strings in sorted order without copying one string into anotherQuick Links :‘Practice Problems’ on Sorting‘Quizzes’ on SortingRecomended:Learn Data Structure and Algorithms | DSA TutorialIf you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.