Rearrange array elements-Pls help

Hi,
Do anyone of you know how to get this done..

consider I have an array array1 (a b c d e).
Now based on some calculations I would get a No. which is the index of the above array.Say for example I get 3.Then, I would remove the third value from the array and rearrange the array as
array1 (d e a b).

Thanks,
Triji:confused:

Which language did you have in mind?

'm trying to learn bash shell scripting..I din know how to go about this!!:confused:

To get a slice of a bash array you can do stuff like

a=(a b c d e)
b=${a[@]:0:2}   # gets a b

So your particular problem could be done with

b=( ${a[@]:3:2} ${a[@]:0:2} )
echo ${b[@]}

If necessary, you could generalise to use a variable instead of the literal '3' and then complute how many elements you need from each slice; you can get the length of the array with ${#a[@]}.

Do you want just a general algorithm or a specific example in some language?