I've been working through the exercises prior to my students to determine where my students may have difficulty.
I have gotten to 5.8.4 - Word Counts in which students are to ask for a phrase, break it down into its individual words and put them in a HashMap and count the number of times each word appears in the phrase. Once the hashmap is built, they are supposed to print the hashmap in order by the key
I have been able to build the hashmap with the proper counts, however, printing the hashmap using a for each loop prints it in a seemingly random order. In the examples leading up to this exercise, there is no mention of how to sort a hashmap. I have looked at several other sources on how to sort a hashmap and all the ones I found bring in information that is never discussed on CodeHS that I have found.
Does anyone have a way to sort or at least print a hashmap in sorted order that uses information found on the CodeHS site? My students will not be reaching this point until after the 1st of the year, so I'll also continue researching as well.