[Python-Dev] sorted()

Greg Ewing greg@cosc.canterbury.ac.nz
Thu, 26 Sep 2002 12:56:47 +1200 (NZST)


pinard@iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard):

> The advantage is that the `.sorted()' method fits well within how
> Python has evolved recently, offering more concise and legible
> writings for frequent idioms.

I prefer the idea of making sorted() a separate function,
because it can then be made to work on any sequence that
can be copied and has a sort() method.

To support specialised non-in-place sorting algorithms,
it could check whether its argument has a sorted()
method, and if not, fall back on the general implementation.

This seems more Pythonic to me.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+