moved all freq_dic functions into one with an optional sort argument, default is freq