how to compare strings lexicographically in python