Hi,
I have a flat file text database with fields separated by pipes.
I have to be able to sort any text field in descending or ascending order. I have tried to use the perl sort function in combination with building up a hash as I have seen in other posts.
I can get it to work if I make the hash in the format:
(val_to_sort_by => row)
i.e. the hash key is the value of the field I am sorting by and the hash value is the entire row.
However this does not suit my purpose because there are case in which the field I am sorting by has duplicate values on various rows. In this case, using the field value as the hash key is not possible because the value is not unique.
I would like to use the perl sorting function as it is neat and quick, but I am thinking I will have to write brute force sorting function myself. Can anyone advise on how to sort such files?
Thanks in advance
Joe Niland
mailto:joe.niland@meniscus.com.au [sig][/sig]
I have a flat file text database with fields separated by pipes.
I have to be able to sort any text field in descending or ascending order. I have tried to use the perl sort function in combination with building up a hash as I have seen in other posts.
I can get it to work if I make the hash in the format:
(val_to_sort_by => row)
i.e. the hash key is the value of the field I am sorting by and the hash value is the entire row.
However this does not suit my purpose because there are case in which the field I am sorting by has duplicate values on various rows. In this case, using the field value as the hash key is not possible because the value is not unique.
I would like to use the perl sorting function as it is neat and quick, but I am thinking I will have to write brute force sorting function myself. Can anyone advise on how to sort such files?
Thanks in advance
Joe Niland
mailto:joe.niland@meniscus.com.au [sig][/sig]