LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sorting in perl (https://www.linuxquestions.org/questions/programming-9/sorting-in-perl-4175529130/)

laurel 12-23-2014 05:52 PM

sorting in perl
 
I want to convert code1 to code2 but I couldn't sort


<CODE1>
foreach my $str(sort keys %count) {
print Output "$str $count{$str}\n";
}

<CODE2>
while (my $str = each %count){
}
continue{
print Output "$str $count{$str}\n";
}

pan64 12-27-2014 09:19 AM

have you tried:
while (my $str = each sort keys %count)
??


All times are GMT -5. The time now is 03:31 AM.