<P> time if enough processors are available . Such a sort can perform well in practice when combined with a fast stable sequential sort, such as insertion sort, and a fast sequential merge as a base case for merging small arrays . </P> <P> Merge sort was one of the first sorting algorithms where optimal speed up was achieved, with Richard Cole using a clever subsampling algorithm to ensure O (1) merge . Other sophisticated parallel sorting algorithms can achieve the same or better time bounds with a lower constant . For example, in 1991 David Powers described a parallelized quicksort (and a related radix sort) that can operate in O (log n) time on a CRCW parallel random - access machine (PRAM) with n processors by performing partitioning implicitly . Powers further shows that a pipelined version of Batcher's Bitonic Mergesort at O ((log n)) time on a butterfly sorting network is in practice actually faster than his O (log n) sorts on a PRAM, and he provides detailed discussion of the hidden overheads in comparison, radix and parallel sorting . </P> <P> Although heapsort has the same time bounds as merge sort, it requires only Θ (1) auxiliary space instead of merge sort's Θ (n). On typical modern architectures, efficient quicksort implementations generally outperform mergesort for sorting RAM - based arrays . On the other hand, merge sort is a stable sort and is more efficient at handling slow - to - access sequential media . Merge sort is often the best choice for sorting a linked list: in this situation it is relatively easy to implement a merge sort in such a way that it requires only Θ (1) extra space, and the slow random - access performance of a linked list makes some other algorithms (such as quicksort) perform poorly, and others (such as heapsort) completely impossible . </P> <P> As of Perl 5.8, merge sort is its default sorting algorithm (it was quicksort in previous versions of Perl). In Java, the Arrays. sort () methods use merge sort or a tuned quicksort depending on the datatypes and for implementation efficiency switch to insertion sort when fewer than seven array elements are being sorted . The Linux kernel uses merge sort for its linked lists . Python uses Timsort, another tuned hybrid of merge sort and insertion sort, that has become the standard sort algorithm in Java SE 7, on the Android platform, and in GNU Octave . </P>

Time complexity of merge sort which is already sorted