Fix sorting in python3