in reply to Returning an array the way it was written
That doesn't look like Perl code.
In Perl the whole point of an array is that it maintains order.
my @x = (3, 1, 2); print "@x"; [download]
3 1 2 [download]