Alan Gauld wrote:
> OK so use Pythons built in sort method. It uses quick sort I believe.

No, it uses 'timsort', an "adaptive, stable, natural mergesort [with] 
supernatural performance on many kinds of partially ordered arrays."

Read about it here:
http://svn.python.org/view/python/trunk/Objects/listsort.txt?rev=51013&view=auto

> But if it doesn't still use it and see if its fast enough. If it isn't 
> consider
> refactoring your data structures to improve it. If that doesn't work 
> then,
> as a last resort, consider writing your own sort function.

Hmmm...IMO there is vanishingly small chance that a sort written in 
Python will be faster than the built-in sort and slim chance that a sort 
written in C will be faster. timsort is at least the third sort 
algorithm to be used in Python - some smart people have been tweaking it 
for a long time.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to