Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages) Last Updated : 13 May, 2022 Comments Improve Suggest changes Like Article Like Report Ever wondered how sort() function we use in C++/Java or sorted() in Python work internally? Here is a list of all the inbuilt sorting algorithms of different programming languages and the algorithm they use internally. C’s qsort() – QuicksortBest Case Time Complexity- O(NlogN)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(N2)Auxiliary Space- O(log N)Stable- Depends on the implementation of the comparator functionAdaptive- NoC++’s sort() – Introsort (Hybrid of Quicksort, Heap Sort and Insertion Sort) Best Case Time Complexity- O(NlogN)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(NlogN)Auxiliary Space- O(logN)Stable- NoAdaptive- NoC++’s stable_sort() - MergesortBest Case Time Complexity- O(NlogN)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(NlogN)Auxiliary Space- O(N)Stable- YesAdaptive- YesJava 6’s Arrays.sort() – QuicksortBest Case Time Complexity- O(NlogN)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(N2)Auxiliary Space- O(logN)Stable- DependsAdaptive- NoJava 7’s Arrays.sort() – Timsort (Hybrid of Mergesort and Insertion Sort)Best Case Time Complexity- O(N)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(NlogN)Auxiliary Space- O(N)Stable- YesAdaptive- YesJava’s Collections.sort() – MergesortBest Case Time Complexity- O(NlogN)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(NlogN)Auxiliary Space- O(N)Stable- YesAdaptive- YesPython’s sorted() – Timsort (Hybrid of Mergesort and Insertion Sort)Best Case Time Complexity- O(N)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(NlogN)Auxiliary Space- O(N)Stable- YesAdaptive- YesPython’s sort() - Timsort (Hybrid of Mergesort and Insertion Sort)Best Case Time Complexity- O(N)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(NlogN)Auxiliary Space- O(N)Stable- YesAdaptive- YesC# sort() – Introsort or introspective sort (Hybrid of Quicksort, Heap Sort and Insertion Sort) Best Case Time Complexity- O(NlogN)Average Case Time Complexity- O(NlogN)Worse Case Time Complexity- O(NlogN)Stable - Depends In the next sets we will implement Introsort ( C++’s sorting weapon ) and Sleep sort, Gnome Sort and other unconventional sorting algorithms. Comment More infoAdvertise with us Next Article Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages) K kartik Improve Article Tags : Sorting DSA Merge Sort Quick Sort Insertion Sort +1 More Practice Tags : Merge SortSorting Similar Reads When to use each Sorting Algorithms | Set 2 Sorting is the process of arranging a set of data in a specific order, which may be numerical (ascending, descending) or lexicographical (alphabetical) order. Why Sorting Is Required? Sorting is very essential when there is a need to highly optimize the searching algorithm. For example, let's assume 5 min read Introduction to Sorting Techniques â Data Structure and Algorithm Tutorials Sorting refers to rearrangement of 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. Why Sorting Algorithms are ImportantThe sorting algorithm is important in Com 3 min read Sorting Algorithm Visualization : Merge Sort The human brain can easily process visuals instead of long codes to understand the algorithms. In this article, a program that program visualizes the Merge sort Algorithm has been implemented. The GUI(Graphical User Interface) is implemented using pygame package in python. Approach: An array of rand 3 min read Radix Sort - Data Structures and Algorithms Tutorials Radix Sort is a linear sorting algorithm that sorts elements by processing them digit by digit. It is an efficient sorting algorithm for integers or strings with fixed-size keys. Rather than comparing elements directly, Radix Sort distributes the elements into buckets based on each digit's value. By 15+ min read Counting Sort - Data Structures and Algorithms Tutorials Counting Sort is a non-comparison-based sorting algorithm. It is particularly efficient when the range of input values is small compared to the number of elements to be sorted. The basic idea behind Counting Sort is to count the frequency of each distinct element in the input array and use that info 9 min read Like