aboutsummaryrefslogtreecommitdiff
path: root/challenge-081/arne-sommer/raku/frequency-sort-map
blob: 0bb2cc39654ef932b0d77b0a4615f8115c68b613 (plain)
1
2
3
4
5
6
7
8
9
10
11
#! /usr/bin/env raku

unit sub MAIN ($file where $file.IO.e && $file.IO.r = "input.txt");

my %freq = $file.IO.slurp.trans(/<[."(),]>/ => ' ').subst("'s", " ", :global).subst("--", " ", :global).words.Bag;

my @freq;

%freq.keys.sort.map({ @freq[%freq{$_}] ~= $_ ~ " " });

@freq.keys.grep({ @freq[$_] }).map({ say "$_ { @freq[$_] }" });