Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix reliance on hash ordering
  • Loading branch information
moritz committed Mar 27, 2014
1 parent 8117230 commit 8a1b7e7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions integration/99problems-21-to-30.t
Expand Up @@ -251,17 +251,18 @@ sub combination($n, @xs) {
#?pugs todo
{
my @input= [<a b c>],[<d e>],[<f g h>],[<d e>],[<i j k l>],[<m n>],[<o>];
my @expected= [<o>],[<i j k l>],[<a b c>],[<f g h>],[<d e>],[<d e>],[<m n>];
my @expected= [<i j k l>],[<o>],[<a b c>],[<f g h>],[<d e>],[<d e>],[<m n>];

# group lists by length

my %grouped;
for (@input) {push %grouped{+$_}, $_}

# now sort the values by frequency, again can't use
# sort: {+$_}
# now sort the values by frequency,
# but since both length 1 and 4 appear twice, need to sort first on
# something else to avoid reliance on hash ordering

my @sorted= %grouped.values.sort: +*;
my @sorted= %grouped.values.sort(*[0][0]).sort: +*;
is @expected,@sorted, "..or according to frequency of length of sublists"
}

Expand Down

0 comments on commit 8a1b7e7

Please sign in to comment.