Formula needed: Sort Array
- by aw
I have the following array:
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
I use it for some visual stuff like this:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Now I want to sort the array like this:
1 3 6 10
2 5 9 13
4 8 12 15
7 11 14 16
//So the original array should look like this:
a = [1,5,2,9,6,3,13,10,7,4,14,11,8,15,12,16]
Yeah, now I'm looking for a smart formula to do that
ticker = 0;
originalArray = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
newArray = [];
while(ticker < originalArray.length)
{
//do the magic here
ticker++;
}