Having trouble sorting code entries by frequency of occurrence