in reply to sort index (head cold)

I'm not quite sure I understand your question, but I think I do. I think a hash would be the easiest way to go.
#!/usr/bin/perl -w use strict; my (@newa, %hash, @sortedlist, @sortedindex); @newa = ('t', 'd', 'z', 'x'); @hash{@newa}=(0..$#newa); @sortedlist=sort @newa; @sortedindex=@hash{@sortedlist}; print "@sortedindex\n"; print "@newa[@sortedindex]\n";
I don't think this is particularly efficient, but it does give the result I think you want. It might be easier to use map, but I haven't figured map out yet.
1 0 3 2 d t x z
is the output.