Implement lexicographical Ord for TreeMap/TreeSet

This is to address issue #4605.