DSU pattern (was Re: Trouble sorting lists (unicode/locale related?))
Peter Otten
__peter__ at web.de
Mon Sep 22 04:49:33 EDT 2003
Jeff Epler wrote:
> If this did work, then you can use the DSU pattern like so:
>
> decorated_wordlist = [(locale.strxfrm(w), w) for w in wordlist]
> decorated_wordlist.sort()
> wordlist[:] = [i[1] for i in decorated_wordlist]
Everytime that someone posts a naive list.sort(compare), the DSU pattern is
proposed to improve execution speed.
So maybe it's about time to change the sort() method to support a second
argument
list.sort(compare=None, mapping=None)
that, if provided, would perform the DSU magic. Or was that already proposed
and rejected?
Peter
More information about the Python-list
mailing list