Q: sort's key and cmp parameters

Hrvoje Niksic hniksic at xemacs.org
Wed Oct 7 08:35:34 EDT 2009


Bearophile <bearophileHUGS at lycos.com> writes:

> What I meant is that a general sorting routine, even in D, is better
> to be first of all flexible. So I think it's better for the D built-in
> sort to be stable, because such extra invariant allows you to use the
> sort in more situations.

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.



More information about the Python-list mailing list