http://www.perlmonks.org?node_id=83717


in reply to Sorting issues

If You insist on "sort" here is my way to do it:
for the database as
1 2 3 |10 a b c |20 e f g |100 x n f |1
the code
#!/usr/bin/perl -w use strict; my %H; open(R,"database"); map {/\|(\d+)/; $H{$1}=$_ if $1}<R>; close(R); foreach (sort {$a<=>$b} keys %H){print $H{$_}}
does exactly:
x n f |1 1 2 3 |10 a b c |20 e f g |100
Enjoy...