sorting with expensive compares?

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

In article <pan.2005. at>,
Dan Stromberg  <strombrg at> 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           <*>

"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