[Python-Dev] Sorting

Barry A. Warsaw barry@zope.com
Mon, 22 Jul 2002 11:09:49 -0400


>>>>> "A" == Aahz  <aahz@pythoncraft.com> writes:

    A> Any reason the list object can't grow a .stablesort() method?

Because when a user looks at the methods of a list object and sees
both .sort() and .stablesort() you now need to explain the difference,
and perhaps give some hint as to why you'd want to choose one over the
other.

Maybe the teachers-of-Python in this crowd can give some insight into
whether 1) they'd actually do this or just hand wave past the
difference, or 2) whether it would be a burden to teaching.  I'm
specifically thinking of the non-programmer crowd learning Python.

I would think that most naive uses of list.sort() would expect a
stable sort and wouldn't care much about any performance penalties
involved.  I'd put my own uses squarely in the "naive" camp. ;)

I'd prefer to see

- .sort() actually /be/ a stable sort in the default case

- list objects not be burdened with additional sorting methods (that
  way lies a footing-challenged incline)

- provide a module with more advanced sorting options, with functions
  suitable for list.sort()'s cmpfunc, and with derived classes
  (perhaps in C) of list for better performance.

-Barry