in reply to Text Manipulation Quickie
Update:#!/usr/bin/perl -w use strict; my %value; for (<DATA>){ chomp; $value{$_}++ if $_; } my $max = (sort map { $value{$_} } keys %value)[-1]; for my $count (1..$max){ for (sort keys %value){ print "$_\n" if $value{$_} >= $count; } } __DATA__ 2 2 2 3 3 3 4 4 4
2 2 2 3 3 3 4 4 5Will return:
2 3 4 5 2 3 4 2 3You can make it work like his second example by reversing the loop:
for my $count (reverse 1..$max){
Update (2): Got rid of pesky newlines per katgirl.
-- grummerX
|
|---|