Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Sorting issues

by zeidrik (Scribe)
on May 28, 2001 at 15:08 UTC ( #83717=note: print w/replies, xml ) Need Help??


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...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://83717]
help
Chatterbox?
[LanX]: ]t
[LanX]: am I the only one who first thinks scifi when a post starts with "Solaris"?

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2017-03-23 19:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (294 votes). Check out past polls.