First: you did a good job on that - excellent progress. Just one problem with the sort:
The Map.Entry class does not implement Comparator, so it has no default or "natural" sort order. That's why you need to create your own Comparator for the sort. The code you found on the web is a good place to start - it defines a Comparator that compares Map.Entry objects by ignoring their keys and comparing their values.