in reply to [SOLVED]How to sort the referencese

Your question is a little unclear but my guess from your partial output is that you want something like this.

use strict; use warnings; use 5.010; my @arr = qw{ A C D D C D A G F }; my $str = join q{}, @arr; say for sort map { substr $str, $_ } 0 .. length( $str ) - 1;

The output.

ACDDCDAGF AGF CDAGF CDDCDAGF DAGF DCDAGF DDCDAGF F GF

I hope I have guessed correctly and that this is helpful.

Update: A version that works on array subscripts rather than offsets into a joined string, using the revised data in the OP.

use strict; use warnings; use 5.010; my @arr = qw{ a c a a a c a t a t z }; my @sortedIndices = map { $_->[ 0 ] } sort { $a->[ 1 ] cmp $b->[ 1 ] } map { [ $_, join q{}, @arr[ $_ .. $#arr ] ] } 0 .. $#arr; say join q{}, @arr[ $sortedIndices[ $_ ] .. $#arr ] for 0 .. $#sortedIndices;

Outputs

aaacatatz aacatatz acaaacatatz acatatz atatz atz caaacatatz catatz tatz tz z

Cheers,

JohnGG