in reply to Condensed rank table output
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11105802 use warnings; my %hash = ( Alec => 14, Alice => 12, Bob => 10, Donny => 13, Jacob => 13, Mike => 11, Sarah => 13, First => 17 ); my $rank = 0; $_ = join '', sort {$b =~ s/\D+//gr <=> $a =~ s/\D+//gr } map " $_ - $hash{$_}\n", sort keys %hash; 1 while s/(.*) - (\d+)\n(.* \2\n)/$1,$3/; s/^(?=(.+))/$1 =~ tr~,~~ < 1 ? ++$rank . '.' : ++$rank . '-' . ($rank += $1 =~ tr~,~~) . '.' /gem; print;
Outputs
1. First - 17 2. Alec - 14 3-5. Donny, Jacob, Sarah - 13 6. Alice - 12 7. Mike - 11 8. Bob - 10
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Condensed rank table output
by tlk (Acolyte) on Sep 08, 2019 at 17:51 UTC | |
by Marshall (Canon) on Sep 09, 2019 at 18:50 UTC | |
by tlk (Acolyte) on Sep 13, 2019 at 20:02 UTC |