Adapting code from this thread gives this ST sort.

use strict; use warnings; use 5.010; my @words = qw{ hypersensitivities zoology chlorofluorocarbons reinterpretations mississipi }; foreach my $word ( @words ) { say qq{\n** $word **}; printf qq{%2d - %s\n}, $_, substr $word, $_ - 1 for sortPosns( $word ); } sub sortPosns { return map { $_->[ 0 ] } sort { $a->[ 1 ] cmp $b->[ 1 ] } map { [ $_, substr $_[ 0 ], $_ - 1 ] } 1 .. length $_[ 0 ]; }

The output.

** hypersensitivities ** 7 - ensitivities 4 - ersensitivities 17 - es 1 - hypersensitivities 16 - ies 14 - ities 10 - itivities 12 - ivities 8 - nsitivities 3 - persensitivities 5 - rsensitivities 18 - s 6 - sensitivities 9 - sitivities 15 - ties 11 - tivities 13 - vities 2 - ypersensitivities ** zoology ** 6 - gy 4 - logy 5 - ogy 3 - ology 2 - oology 7 - y 1 - zoology ** chlorofluorocarbons ** 14 - arbons 16 - bons 13 - carbons 1 - chlorofluorocarbons 7 - fluorocarbons 2 - hlorofluorocarbons 3 - lorofluorocarbons 8 - luorocarbons 18 - ns 12 - ocarbons 6 - ofluorocarbons 17 - ons 10 - orocarbons 4 - orofluorocarbons 15 - rbons 11 - rocarbons 5 - rofluorocarbons 19 - s 9 - uorocarbons ** reinterpretations ** 12 - ations 2 - einterpretations 6 - erpretations 10 - etations 3 - interpretations 14 - ions 16 - ns 4 - nterpretations 15 - ons 8 - pretations 1 - reinterpretations 9 - retations 7 - rpretations 17 - s 11 - tations 5 - terpretations 13 - tions ** mississipi ** 10 - i 8 - ipi 5 - issipi 2 - ississipi 1 - mississipi 9 - pi 7 - sipi 4 - sissipi 6 - ssipi 3 - ssissipi

Weirdly satisfying throwing odd words at it! I've no idea how it might perform in the benchmarks but I thought I'd post in case it is of interest.

Cheers,

JohnGG


In reply to Re: suffix array efficiency by johngg
in thread suffix array efficiency by RobertCraven

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.