On 2/18/2014 2:35 AM, Greg Ewing wrote:
results = sorted(invoices, key=attrgetter('duedate'), none='first')
I think this is the best idea on the thread. As a pure enhancement, it
could be added in 3.5. The only tricky part of the implementation is
maintaining stability of the sort. The obvious implementation of
swapping Nones with objects at one end would break that. Instead, a scan
listing the positions of Nones should be followed by a series of block
moves of objects (pointers) between the Nones. It would still be O(n).
--
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com