On Wed, Apr 05, 2006 at 06:10:41PM -0400, Matthew Good wrote:
> Well, if there's no key you can skip most of the logic for sorting on
> the key:
>
> if key is None:
> lst = list(iterable)
> lst.sort()
> return lst
>
> I hadn't bothered to add this before since I added "sorted" primarily to
> replace the situations where Trac previously used a custom comparison
> method. If it's useful I can make Trac's "sorted" implementation more
> complete.
>
> Also, if you already have a list, sort it in place if possible:
> "lst.sort()". Using "sorted" will copy the existing list, so it's less
> efficient. If you're sorting an iterator/generator then "sorted" is
> convenient.
Hi Matt,
It's sorting set() objects mostly in the tag plugin.
But back to the sorted() implementation. The bug is fixed in trunk by
changing this:
lst = [(key(i), i) for i in iterable]
to this:
lst = key and [(key(i), i) for i in iterable] or list(iterable)
I guess it would be ideal if the tags plugin did the same, or explicitly
passed key= to avoid the bug altogether.
Alec
--
Evolution: Taking care of those too stupid to take care of themselves.
_______________________________________________
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac