# Multiple swapping of rows and columns

m={{a, b, c, p}, {d, e, f, x}, {g, h, k, z}, {u, v, w, y}};


I want to swap 1st and 2nd rows by 4th and 3rd rows respectively. And then, swap 1st and 2nd columns by 4th and 3rd columns.

-
Reverse[m, {1, 2}]. Related: (2546) and (19726) – Kuba Apr 29 '14 at 15:52
I don't think it is obvious that Reverse has second argument, but if you need to reverse something it is easy to face it in docs :) So my point is that it should be closed, but let's see what community says :) – Kuba Apr 29 '14 at 16:03
@Kuba Unless it's a dup (I don't know), I think you could post it as an answer – Dr. belisarius Apr 29 '14 at 16:07
Also related: (3069) and (20228) – Mr.Wizard Apr 29 '14 at 23:33

OK, encouraged by belisarius, here's the way.

If you know that Reverse exists you may use:

Reverse /@ Reverse @ m


then you could check the docs and realise that Reverse has 2nd argument:

Reverse[m, {1, 2}]


But if you don't but you are amazed by Span+Part you can end up with:

m[[;; , {4, 3, 2, 1}]][[{4, 3, 2, 1}]]


or even more Span: :)

m[[;; , -1 ;; 1 ;; -1]][[-1 ;; 1 ;; -1]]


Why is multidimensional Reverse slow? - nice question where I've learned about -1;;1;;-1

-
Congratulations on joining the 20K club! :-) For some reason I still think of you as a "new" member but you have become a pillar of the community, and not by "reputation" alone. – Mr.Wizard Apr 29 '14 at 23:35
@Mr.Wizard Thank you for those kind words :) I do enjoy being here :), almost each day I can learn, or at least face, something new so thank you community of Mathematica.SE :) – Kuba Apr 30 '14 at 5:12