solved frequency  sorting