Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Sorting Strings By Vowel Sequence

by Anonymous Monk
on Nov 18, 2014 at 04:31 UTC ( [id://1107526]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Sorting Strings By Vowel Sequence
in thread Sorting Strings By Vowel Sequence

Now that I think of it, it can be greatly simplified:
sub prepare_sort { return [ $_, tr/aeiou/z/cr, tr/aeiou//dr ]; }
Thanks to Zucan for the tip!

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
    map [ $_, tr/aeiou/ /r, tr/aeiou//cdr ]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1107526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found