Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Perl sorting unique values

by pr09 (Novice)
on Jun 23, 2011 at 08:06 UTC ( [id://911023]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl sorting unique values
in thread Perl sorting unique values

Got the desired output:
# use strict; #use warnings; my %hash; open my $fh, '<','abc.txt' or die $!; while (<$fh>) { chomp; my ($key, $val , $val1) = split '\|'; $hash{$val1}++; } @sorted= reverse sort keys %hash; #print "After reverse sorting @sorted\n"; ################sorts and prints the array salaries in descending orde +r for($i=0;$i<=20;$i++) { for($j=$i+1;$j<=20;$j++) { if ($sorted[$i] < $sorted[$j]) { $temp = $sorted[$i]; $sorted[$i] = $sorted[$j]; $sorted[$j] = $temp; } } } print "The salaries in unique and sorted descending order are\n"; print "@sorted\n";
Thanks All.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://911023]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-05-21 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found