Author: Anjan PurkayasthaAnjan Purkayastha
Date: May 15, 2008 10:13
Hi,
here is a problem I'm working on. It's not PERL-specific, rather it is a
problem in sorting followed by grouping.
Suppose I have a set of lines that have tab-delimited text, thus:
1 w 3 wer
2 a 4 rte
4 w 2 weg
6 d 4 fhg
5 d 7 dfl
6 w 4 ald
8 a 3 dsl
I would like to first sort the lines based on the 2nd token (w,a, w, d, etc)
and then group the lines based on the 2nd token.
At the end of this sorting/grouping I should have the lines grouped thus:
2 a 4 rte
8 a 3 dsl
6 d 4 fhg
5 d 7 dfl
|