Based on Simple lexicographical sorting