Use SortedMap instead of Map as interface since SortedMap is a more accurate interface used here.