in reply to Re: Sorting issue
in thread Sorting issue

Hi jdporter,

I have tried the custom sort previously. But it gave the error message "Use of uninitiated value.. " for each line. So, I checked the input file for repeats in the frequency column and it is repeated. I guess, there will be a clash in the way hash stores each values. In the first column of output file, I also concatenated the tag column (first column of input file) to make it unique. Now, I am thinking of sorting with respect to the first column of output file. So far, not successful. Currently, my output file look like this:

Header Tags Frequency >HWTI_2_78439EEEEEMMMMMG EEEEEMMMMMG 2 >HWTI_3_338554FFEFFFDFEMM FFEFFFDFEMM 3 -------------------------------------------

Replies are listed 'Best First'.
Re^3: Sorting issue
by aaron_baugher (Curate) on Nov 05, 2011 at 01:44 UTC

    Duplicate values in a hash aren't a problem; only duplicate keys are. So if your tags are never repeated, you'll be fine putting each input line's tag as the hash key and the frequency as its value.

    When it comes time to sort, you can only sort your hash on something that's in your hash. So if your hash contains the tags and frequencies, you can sort on either of those (see my last reply for how to sort on the values); but you can't sort on the header that you haven't created yet.

      The keys (tags) are unique.