in reply to Re: Is it possible to make reference to substrings and sort them?
in thread Is it possible to make reference to substrings and sort them?
If you can spare the memory to double your text, you can create references to all your rotations. Below I use the Schwartzian transform to create the references once, then sort them.
my $text2 = "$text$text"; my $bwt4 = join('', map{substr($text, ($_ - 1), 1)} map{ $_->[0] } sort{ ${$a->[1]} cmp ${$b->[1]} } map{ [$_,\substr($text2,$_,$ntext)] } 0..$ntext-1 ); print "$text: $bwt4\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is it possible to make reference to substrings and sort them?
by Anonymous Monk on Mar 22, 2015 at 19:17 UTC |