Normally for a Map your suspicion would be correct. By definition of the Map interface the items in it are not ordered, and by definition of the Set interface its items are also not ordered.
But....
The TreeMap implementation of the Map interface maintains element order by its keys. In addition, the TreeMap implementation of keySet() returns an implementation of Set that also maintains order by its values, i.e. the Map keys. All of these details are contained in the
JavaDoc for TreeMap which which you could have answered your own question. Familiarity with the JavaDoc is a great resource to keep in your tool kit.