how to compare two strings lexicographically in python