Dave, Thanks very much, it worked a treat except where there was a blank instead of a numeric, so I must tidy up my data first! I still might put it into mySQL though, there is so much more you can do when it is in a database. Regards, Mark -----Original Message----- From: redsquirreldesign [SMTP:[EMAIL PROTECTED]] Sent: 26 June 2001 14:50 To: Bedish, Mark; beginners Cc: redsquirreldesign Subject: Re: sort by value? Mark Bedish wrote: > Dave, > > >It looks to me that your hash %ch is empty. Your > >foreach will never begin because there is no list > to > >iterate. You need to assign keys & values to %ch. > > >When it is time to sort numerically, use the > spaceship > >operator <=>. So it would look like this: > > >sort { $ch{1} <=> $ch{2} } > > No I have got the data, I didnt show the full > example. My tab delimited > file is something like this: > > Complete music of Ockeghem 380 > Bach Cantatas bwv140 etc 113 > Achirana Marshall Trio 48 > Hello Children 145 [snip] Mark, OK, I understand. Using the data you provided above, this code worked for me: ------------------ my (%ch, @fields); open(FILE, "data"); while (<FILE>) { chomp; @fields = split(/\t/); $ch{$fields[0]} = $fields[1]; } close FILE; for (sort { $ch{$a} <=> $ch{$b} } keys %ch) { print "$_: $ch{$_}\n"; } ===== Dave Hoover "Twice blessed is help unlooked for." --Tolkien http://www.redsquirreldesign.com/dave __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/