Added curly braces for the loop
Changed the original sorting method: creating and throwing an exception it costs then using getOrDefault for a map