On 16.10.2016 09:35, Alireza Rafiei wrote:
Awesome! Thanks for the thorough explanation.


Indeed. I also didn't know about that detail of reversing. :) Amazing. (Also welcome to the list, Alireza.)


        def multisort(xs, specs):
            for key, reverse in reversed(specs):
                xs.sort(key=key, reverse=reverse)

    That's all it takes!  And it accepts any number of items in `specs`.
    Before you worry that it's "too slow", time it on real test data.
    `.sort()` is pretty zippy, and this simple approach allows using
    simple key functions.  More importantly, it's much easier on your
    brain ;-)



@Tim
Do you think that simple solution could have a chance to be added to stdlib somehow (with the possibility of speeding it up in the future)?


Regards,
Sven
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to