Hi,

well I'm trying to write a program that needs to sort the suffixes of an array. Let A be an array of characters:

@A = (A,C,D,D,C,D,A,G,F);
now to sort the suffixes I would naively brake and array into 9 suffix arrays and the sort them out and get something like this:
 
ACDD...
AGF
CDA...
CDD...
DAG...
....


now, how do i do this without chopping thees into sub-arrays, and just do it via references like in c, where you do this through pointers (references).

thnx

baxy

UPDATE:

well thnx ppl for the quick help but there is still a problem that i was not aware of ..... so in the following code i get a strange solution:

#!/usr/bin/perl use strict; my @array = qw(a c a a a c a t a t z); my @sorted = sort { $array[$a] cmp $array[$b] } (0 .. $#array); print join('',@array[$sorted[$_] .. $#array]) . "\n" for 0..10; #prints acaaacatatz aaacatatz aacatatz acatatz atatz atz caaacatatz catatz tatz tz z
isn't "acaaacatatz" lexicographically lower then "aacatatz" ???????(SOLVED : see the code below) Oh , I just saw your other comments , so what i'm playing arround is Kasai's algorithm so the whole code is : ---

UPDATE2 : all corrected and below is the working code if anyone needs is, it is a bit naive but illustrates the point and it works Code was moved to : Kasai's algorithm so if someone is looking for it, well here it is , in Perl !!!!


In reply to [SOLVED]How to sort the referencese by baxy77bax

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.