in reply to Re: Help on array element counting
in thread Help on array element counting
Or to sort them by fruits (changing the sort)@fruits = qw/ MANGO APPLE GRAPES MANGO MANGO MANGO MANGO APPLES APPLES BANANA CORN APPLES /; map { $count{$_}++ } @fruits; foreach (sort {$count{$a} <=> $count{$b}} keys %count) { print "$_ => $count{$_}\n"; }
foreach (sort {lc($a) cmp lc($b)} keys %count) { print "$_ => $count{$_}\n"; }
|
|---|