sortlist = ["121","213","602","040"] sortlist.sort(key=lambda x: x[1]) print sortlist #['602', '213', '121', '040']