Fastest way to sort in Python

后端 未结 9 2077
太阳男子
太阳男子 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

    Radix sort theoretically runs in linear time (sort time grows roughly in direct proportion to array size ), but in practice Quicksort is probably more suited, unless you're sorting absolutely massive arrays.

    If you want to make quicksort a bit faster, you can use insertion sort] when the array size becomes small.

    It would probably be helpful to understand the concepts of algorithmic complexity and Big-O notation too.

提交回复
热议问题