Matching games rotation

can i know how to do the matching games rotation,what matrix algorithm nd to use.

FROM
1 2 3 4
5 6 7 8
9 A B C
D E F G

TO
D 9 5 1
E A 6 2
F B 7 3
G C 8 4