You can usually define custom comparison methods so that sorting is within your limits. I have never encoded a Python string in my life, but it is similar to Ruby enough for it to notice that the following excerpt from this page may help you:
alphabet = "zyxwvutsrqpomnlkjihgfedcba" inputWords = ["england", "france", "spain", "italy", "greece", "portugal", "canada", "usa", "mexico", "peru", "cuba", "chile", "argentina", "zimbabwe", "uganda", "congo", "zambia", "namibia", "ghana"] print sorted(inputWords, key=lambda word: [alphabet.index(c) for c in word])
You can also check out these articles , Good luck!
Jeriko
source share