I
I
IKNCODE2019-07-19 17:36:01
Python
IKNCODE, 2019-07-19 17:36:01

What is best for Python? Sort() or selection sort?

I came across one dilemma, which is better to use for Python. sort() sorting method or is it better to use selection sorting algorithm?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tsarevfs, 2019-07-19
@IKNCODE

If this is not a learning task, the purpose of which is to learn how to write a sort, use the standard one.
Selection sort works for the square of the number of elements. An array of 1000 elements will require about 1,000,000 comparisons.
Standard is a variation on the theme of quick sort. Runs in O(n * log(n)). This is about 100 times faster.
The larger the array, the larger the gap will be.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question