Sorting Elements Based On Frequency Distribution