I want this StackOverflow answer to die. Permanently. I hate it. (The question is "how to sort a map by value.")

It breaks in several really confusing ways if you even look at it funny. If the backing map changes, it will break. If multiple keys map to the same value, it will break. If you call get on a key that isn't in the backing map, it will break. If you do anything whatsoever that would cause a lookup to happen on a key that isn't in the map -- a Map.equals call, containsKey, anything -- it will break with really weird stack traces.

I probably shouldn't get so worked up about it, but it's just such an insidiously bad approach. I almost want Guava to add a feature to address sorting maps by value just so people won't use this terrible approach.
Shared publiclyView activity