[Python-Dev] python 3 niggle: None < 1 raises TypeError

Terry Reedy tjreedy at udel.edu
Tue Feb 18 16:53:33 CET 2014

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

More information about the Python-Dev mailing list