A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/038779.html below:

[Python-Dev] decorate-sort-undecorate

[Python-Dev] decorate-sort-undecorateGreg Ewing greg at cosc.canterbury.ac.nz
Wed Oct 15 19:33:03 EDT 2003
Ian Bicking <ianb at colorstudy.com>:

> Okay, really I'm just hoping for [x for x in l sortby key(x)], if
> not now then someday -- if only there was a decent way of expressing
> that without a keyword... [...in l : key(x)] is the only thing I can
> think of that would be syntactically possible (without introducing a
> new keyword, new punctuation, or reusing a wholely inappropriate
> existing keyword).

   [x >> key(x) for x in l] # ascending sort
   [x << key(x) for x in l] # descending sort

(Well, we got print >> f, so it was worth a try...)

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

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4