http://www.perlmonks.org?node_id=936084


in reply to Re^3: Sorting issue
in thread Sorting issue

There is no need for the sort and print loop after the while loop. His input file is already sorted by frequency in descending order (your sample data would be sorted in descending order). So, the make_header() call and print routine could be done within the while loop.