sorting with expensive compares?

Aahz aahz at pythoncraft.com
Fri Dec 23 16:13:11 CET 2005


In article <pan.2005.12.22.22.04.42.519360 at dcs.nac.uci.edu>,
Dan Stromberg  <strombrg at dcs.nac.uci.edu> wrote:
>
>Python appears to have a good sort method, but when sorting array
>elements that are very large, and hence have very expensive compares,
>is there some sort of already-available sort function that will merge
>like elements into a chain, so that they won't have to be recompared as
>many times?

I'll just note that Python's sort is specifically designed to reduce the
number of compares precisely because *all* compares in Python are
relatively expensive.  I'll suggest a variant on the previous suggestion
of hash:

[a] -> [hash(a), index(a), a]
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck."  --USENET schmuck (aka Robert Kern)



More information about the Python-list mailing list