Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^3: Sorting Strings By Vowel Sequence

by Loops (Curate)
on Nov 18, 2014 at 02:39 UTC ( #1107519=note: print w/replies, xml ) Need Help??

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

Well it wasn't part of the original problem statement, so the solution allows sort to pick any order it chooses for elements with the same vowel string. You can tack on the original word to the end of the vowels string to sort by consonants when vowel strings match.

Here is that idea, but using GRT Sort instead of ST:

use 5.014; say join ', ', map {s/.*\0//r} sort map {tr/aeiou//cdr."\0$_"} qw( xexix babebib xaxexi babebibb );
babebib, babebibb, xaxexi, xexix

Replies are listed 'Best First'.
Re^4: Sorting Strings By Vowel Sequence
by Zucan (Beadle) on Nov 18, 2014 at 02:52 UTC

    Nice. Since I added the second edge case, the above still doesn't address the sorting of "babebib" and "baebbib". Even though the first one is alphabetically first, the second should be first based on the positioning of the second vowel. That is at least how I would read the problem.

    You are right, however, the initial problem was loosely stated, so there is definitely room for interpretation.

    Update: The second case may not apply here because the initial question provides sample output that doesn't include the positioning of the vowels in the words. If positioning mattered, the output would actually be the following instead:

    apparate albacore albatross panacea fanfare false parmesan candelabra +beans vermeil

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2022-08-19 05:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found