I apologize if I misunderstand your aim. Here is a first attempt.
m = {{8, 23, 1, 3, 19}, {25, 4, 21, 7, 15}, {5, 9, 17, 21, 12}, {10,
3, 5, 15, 15}, {17, 15, 10, 16, 11}};
fun[lst_] := Module[{st, lg, md, mx},
st = Sort[lst];
lg = Length[lst];
md = Floor[lg/2];
If[Mod[lg, 2] == 1,
Take[st, md]~Join~{Last@st}~Join~Reverse[Take[Most@st, -md]],
Take[st, md]~Join~{Last@st}~Join~Reverse[Take[Most@st, -(md - 1)]]
]]
Visualizing:
mg1 = BarChart3D[m, ChartLayout -> "Grid",
ViewPoint -> {5.03239650286209`, -2.7440079512451665`,
8.668644980704006`}];
mg2 = BarChart3D[fun /@ Transpose[fun /@ m], ChartLayout -> "Grid",
ViewPoint -> {5.03239650286209`, -2.7440079512451665`,
8.668644980704006`}];
GraphicsRow[{mg1, mg2}, ImageSize -> 600]
Testing on a larger set:
test = RandomInteger[{0, 10}, {30, 30}];
tg1 = BarChart3D[test, ChartLayout -> "Grid",
ViewPoint -> {5.03239650286209`, -2.7440079512451665`,
8.668644980704006`}]
tg2 = BarChart3D[fun /@ Transpose[fun /@ test], ChartLayout -> "Grid",
ViewPoint -> {5.03239650286209`, -2.7440079512451665`,
8.668644980704006`}]
eg2 = GraphicsRow[{tg1, tg2}, ImageSize -> 600]
May not be your aim (could have also used MatrixPlot
for visualization).
11
and10
has no sense to me. Could you make your wish more precise? $\endgroup$tmp = (Sort /@ Transpose@m); With[{c = Ceiling[Length@tmp[[1]]/2]}, tmp[[All, c ;;]] = tmp[[All, -1 ;; c ;; -1]]]; tmp // Transpose
$\endgroup$