Somewhat related to Sort matrix by columns and rows without changing them, but more general.
I'd like to sort a square matrix (a 3 by 3 in my case, but surely the general solution will treat any), say, M = {{i, b, c}, {d, e, f}, {g, h, a}}
, into lexicographic form without changing Abs[Det[M]]
, so all row, column and diagonal swaps are allowed. In the example the wanted result would be {{a, c, f}, {h, b, e}, {g, i, d}}
. Obviously I can't split the sorting into row, column and diagonal sorts separately. (The latter CAN be split off but this would still require in my own dumb algorithm: write down the 36 permuted orderings explicitly and pick the first.)
Surely you have a more intelligent (and completely unintelligible, for a n00b like me :-) sorting algorithm? (Like, sorting the list on all levels simultaneously? Only I don't know how yet. Guess it needs a lot of ampersands and octothorpes :-) BTW, I need it to sort a (formal) 9j symbol list and eliminate equivalent duplicates.
h > g
(rows are not ordered according to lex) andh > b
(columns are not ordered...). $\endgroup$Det
restriction. I have yet to think of a good way to approach such a problem so I don't have an output to compare. $\endgroup$