in reply to Is it possible to make reference to substrings and sort them?

This is how I implemented BW for Rosalind.info:
my @suff = 0 .. length $string; pop @suff; @suff = sort { substr($string, $a) cmp substr $string, $b } @suff; for my $idx (@suff) { print substr $string, $idx - 1, 1; } print "\n";

Update: Now I noticed they mentioned O(|Text|) solution wasn't needed in the Note.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Is it possible to make reference to substrings and sort them?
by hdb (Monsignor) on Mar 22, 2015 at 12:06 UTC

    Your algorithm is somewhat different from the OP's in that you do not sort cyclic rotations at all, only the variable length endings of the text.