in reply to Re^3: Sorting Strings By Vowel Sequence
in thread Sorting Strings By Vowel Sequence
Thanks to Zucan for the tip!sub prepare_sort { return [ $_, tr/aeiou/z/cr, tr/aeiou//dr ]; }
So we dont need a sub now:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my @words = qw( xaxexix babebib xaxexi babebibb baebbib ); say for map $_->[0], sort { $a->[2] cmp $b->[2] } # vowels sort sort { $a->[1] cmp $b->[1] } # positional sort sort { $a->[0] cmp $b->[0] } # alphabetical sort map [ $_, tr/aeiou/z/cr, tr/aeiou//dr ], @words;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Sorting Strings By Vowel Sequence
by Anonymous Monk on Nov 18, 2014 at 04:49 UTC |