[Python-Dev] decorate-sort-undecorate
Greg 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