[Duncan Booth] > The documentation doesn't say anything directly about stability, but the > implementation is actually stable. You can probably assume it must be at > least for nlargest and nsmallest otherwise the stated equivalence wouldn't > hold: > > e.g. nsmallest documentation says: > > Equivalent to: sorted(iterable, key=key)[:n]
Yes. The code for nsmallest and nlargest preserves stability so that the equivalence is maintained. Raymond -- http://mail.python.org/mailman/listinfo/python-list