moved the sorting into its own method and reordered the map along with the sorting