Solved

# Unix Sorting Challenge

Posted on 2007-03-22

Here's a sorting challenge. You can use Unix sort command or Perl/awk. Price to the most succinct answer.

Given the following input file:

fx_act1_r-2006-04-29.lis,1

fx_act2_r-2006-04-29.lis,1

fx_act1_r-2006-04-26.lis,10

fx_act1_r-2006-04-26.lis,11

fx_act1_r-2006-04-26.lis,9

fx_act1_r-2006-04-27.lis,10

fx_act1_r-2006-04-27.lis,28

fx_act1_r-2006-04-27.lis,8

fx_act1_r-2006-04-27.lis,9

fx_act1_r-2006-04-28.lis,10

fx_act1_r-2006-04-28.lis,11

fx_act1_r-2006-05-01.lis,21

fx_act1_r-2006-05-01.lis,22

fx_act2_r-2006-04-26.lis,10

fx_act2_r-2006-04-26.lis,11

the file needs to be sorted alphabetically by filename (eg: fx_act1_r), then by date (eg: 2006-04-27), then by sequence number suffix (eg: 11)

So for the above input, the sorted output would be:

fx_act1_r-2006-04-26.lis,9

fx_act1_r-2006-04-26.lis,10

fx_act1_r-2006-04-26.lis,11

fx_act1_r-2006-04-27.lis,8

fx_act1_r-2006-04-27.lis,9

fx_act1_r-2006-04-27.lis,10

fx_act1_r-2006-04-27.lis,28

fx_act1_r-2006-04-28.lis,10

fx_act1_r-2006-04-28.lis,11

fx_act1_r-2006-04-29.lis,1

fx_act1_r-2006-05-01.lis,21

fx_act1_r-2006-05-01.lis,22

fx_act2_r-2006-04-26.lis,10

fx_act2_r-2006-04-26.lis,11

fx_act2_r-2006-04-29.lis,1

Be creative!