Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: Perl sorting unique values

by pr09 (Novice)
on Jun 23, 2011 at 08:06 UTC ( #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? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2023-03-29 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (70 votes). Check out past polls.

    Notices?