FREQUENCIES: Simplify code for sorting the frequency table.