Im am struggling with a script to sort by column 2 first and then column 4. Here is what my list looks like:
E78343 2008/07/26 08:54:29 TYPE1
E78351 2008/07/26 08:54:30 TYPE2
E78365 2008/07/26 08:54:32 TYPE1
E42692 2008/07/26 10:08:02 TYPE1
E243687 2008/07/26 10:14:58 TYPE3
E64527 2008/07/30 07:56:36 TYPE1
E75799 2008/07/31 07:40:11 TYPE2
E75808 2008/07/31 07:40:11 TYPE2
E75830 2008/07/31 07:40:18 TYPE3
here is what ive tried:
#!/usr/bin/env perl
any help would be appreciated
open(IN, "sorted.lst");
@data = <IN>;
@sorted_users =
map { $_->[2] }
sort { $a->[0] <=> $b->[0] || $a->[1] cmp $b->[1] }
map { [ length $_[1], $_[0], $_ ] } # step 1
@data;
print "@sorted_users";
E78343 2008/07/26 08:54:29 TYPE1
E78351 2008/07/26 08:54:30 TYPE2
E78365 2008/07/26 08:54:32 TYPE1
E42692 2008/07/26 10:08:02 TYPE1
E243687 2008/07/26 10:14:58 TYPE3
E64527 2008/07/30 07:56:36 TYPE1
E75799 2008/07/31 07:40:11 TYPE2
E75808 2008/07/31 07:40:11 TYPE2
E75830 2008/07/31 07:40:18 TYPE3
here is what ive tried:
#!/usr/bin/env perl
any help would be appreciated
open(IN, "sorted.lst");
@data = <IN>;
@sorted_users =
map { $_->[2] }
sort { $a->[0] <=> $b->[0] || $a->[1] cmp $b->[1] }
map { [ length $_[1], $_[0], $_ ] } # step 1
@data;
print "@sorted_users";