Fastest way to sort in Python

后端 未结 9 2098
太阳男子
太阳男子 2021-02-13 02:56

What is the fastest way to sort an array of whole integers bigger than 0 and less than 100000 in Python? But not using the built in functions like sort.

Im looking at th

9条回答
  •  眼角桃花
    2021-02-13 03:06

    Early versions of Python used a hybrid of samplesort (a variant of quicksort with large sample size) and binary insertion sort as the built-in sorting algorithm. This proved to be somewhat unstable. S0, from python 2.3 onward uses adaptive mergesort algorithm.

    Order of mergesort (average) = O(nlogn). Order of mergesort (worst) = O(nlogn). But Order of quick sort (worst) = n*2

    if you uses list=[ .............. ]

    list.sort() uses mergesort algorithm.

    For comparison between sorting algorithm you can read wiki

    For detail comparison comp

提交回复
热议问题