Improved sort

I used default python sort (first value), to prevent unneeded calls to
key function.