The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 07-05-2009
summer_cherry summer_cherry is online now Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092
how about below perl:


Code:
my @arr=<DATA>;
print map {$_->[0]}
      sort {$a->[1]->[2] cmp $b->[1]->[2] or $a->[1]->[1] cmp $b->[1]->[1]}
      map {my @tmp=split(";",$_);[$_,\@tmp]}
      @arr;
__DATA__
US to UK;abc-hq-jcl;multimedia
UK to CN;def-ny-jkl;standard
DE to DM;abc-ab-klm;critical
FD to YM;la-yr-tym;standard
HY to MC;la-yr-ytm;multimedia
GT to KJ;def-ny-jrt;critical