Suppose I have the following list:
Tl={{a, 3, b}, {c, 6, d}, {e, 9, f}, {g, 5, h}}
I really want to reverse specific elements of this list such that I get the following:
lT= {{b,5, a}, {d, 9, c}, {f, 6, e}, {h, 3, g}}
The best I could do is:
Reverse /@ tl
(* output: {{b, 3, a}, {d, 6, c}, {f, 9, e}, {h, 5, g}} *)
Any suggestions? The method should hold for any even number (say N
) of sublists (consisting of 3 elements) in the original data set. As can be seen, N=4
for this case.
lt=tl;lt[[All,2]]=Reverse@lt[[All,2]]
$\endgroup$