views:

30

answers:

1

I have a 2D array

1 2 3
4 5 6
7 8 9

and want to sort it like this

Snake

1 2 3
8 9 4
7 6 5

Snake (different)

1 2 3
6 5 4
7 8 9

Rotated

1 4 7
2 5 8
3 6 9

Wipe (diagonal)

1 3 6
2 5 8
4 7 9

Well, you got it, all kinds of sorting.

Searching the interweb for hours now. Any resources (specific language or pseudo code) on that greatly appreciated...

+3  A: 

Suggestion: Dump all values in a 1D-array and sort there. Then define the patterns for filling using multiple for loops.

Christopher Oezbek
Why not? However, any resources for sorting the array then?
aw
You mean 1D sort? -> Arrays.sort()
Christopher Oezbek