With sort and a regexp:
#!/usr/bin/perl -w use strict; my $re = qr/\| \w+ \s+ (\w+) \|/msx; print sort { my ($aa) = $a =~ $re; my ($bb) = $b =~ $re; $aa cmp $bb; } <DATA>; __DATA__ 123|Pete Smith|4321|321G4 2134|Mike Malarky|93F821 83|Dave Waylaid|8374W Output : 2134|Mike Malarky|93F821 123|Pete Smith|4321|321G4 83|Dave Waylaid|8374W
hth,
PooLpi
In reply to Re: custom sorting
by poolpi
in thread custom sorting
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |