[Python-Dev] decorate-sort-undecorate

Duncan Booth duncan at rcp.co.uk
Wed Oct 15 04:42:37 EDT 2003

Guido van Rossum <guido at python.org> wrote in 
news:200310141958.h9EJwFu24582 at 12-236-54-216.client.attbi.com:

>> Don't you still need a tie-breaker index to preserve stability?
> No, because the sort algorithm is already stable.

What about the situation where you want the list sorted in reverse order? 
If you simply sort and then reverse the list you've broken the stability. 

You *could* preserve the stability by using a negative index when the list 
is to be reserved, but might it also be possible to get the special 
comparison object to invert the result of the comparison?

Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

More information about the Python-Dev mailing list