title: How to flip/reverse a 2D array's rows or columns using STL
body: <p>I have a 2D array of arbitrary type, of dimensions <code>N x M</code> (i.e., <code>T array[N][M];</code>) e.g.,</p>
  
  <p><img src="https://latex.codecogs.com/gif.latex?%5Cmathbf%7BM%7D&space;=&space;%5Cbegin%7Bbmatrix%7D&space;1&space;&amp;&space;2&space;&amp;&space;3&space;%5C%5C&space;4&space;&amp;&space;5&space;&amp;&space;6%5C%5C&space;7&space;&amp;&space;8&space;&amp;&space;9%5C%5C&space;10&amp;&space;11&amp;&space;12&space;%5Cend%7Bbmatrix%7D" title="\mathbf{M} = \begin{bmatrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6\\ 7 &amp; 8 &amp; 9\\ 10&amp; 11&amp; 12 \end{bmatrix}" /></p>
  
  <p>that I want flip it either its <strong>columns</strong> e.g., </p>
  
  <p><img src="https://latex.codecogs.com/gif.latex?%5Cmathbf%7BM%7D&space;=&space;%5Cbegin%7Bbmatrix%7D&space;3&amp;&space;2&space;&amp;&space;1&space;%5C%5C&space;6&amp;&space;5&space;&amp;&space;4%5C%5C&space;9&amp;&space;8&space;&amp;&space;7%5C%5C&space;12&amp;&space;11&amp;&space;10&space;%5Cend%7Bbmatrix%7D" title="\mathbf{M} = \begin{bmatrix} 3&amp; 2 &amp; 1 \\ 6&amp; 5 &amp; 4\\ 9&amp; 8 &amp; 7\\ 12&amp; 11&amp; 10 \end{bmatrix}" /></p>
  
  <p>or its <strong>rows</strong> e.g.,</p>
  
  <p><img src="https://latex.codecogs.com/gif.latex?%5Cmathbf%7BM%7D&space;=&space;%5Cbegin%7Bbmatrix%7D&space;10&amp;&space;11&amp;&space;12%5C%5C&space;7&space;&amp;&space;8&space;&amp;&space;9%5C%5C&space;4&space;&amp;&space;5&space;&amp;&space;6%5C%5C&space;1&space;&amp;&space;2&space;&amp;&space;3&space;%5Cend%7Bbmatrix%7D" title="\mathbf{M} = \begin{bmatrix} 10&amp; 11&amp; 12\\ 7 &amp; 8 &amp; 9\\ 4 &amp; 5 &amp; 6\\ 1 &amp; 2 &amp; 3 \end{bmatrix}" /></p>
  
  <p>How can I do this easily just using STL?</p>