Q: sort's key and cmp parameters

Raymond Hettinger python at rcn.com
Wed Oct 7 19:15:15 CEST 2009

[Hrvoje Niksic]
> Note that stable sort has additional memory requirements.  In situations
> where you don't need stability, but do need memory-efficient in-place
> sorting, an unstable sort might well be preferred.  This is why
> libraries such as C++'s STL offer both.

FWIW, the "additional memory requirements" are typically a set of
pointers to the objects being sorted, so the memory overhead is
typically very small relative to the size of the objects being sorted.
IOW, this isn't much of a consideration in most Python apps.


More information about the Python-list mailing list