Suppose I have some diagonal matrix whose nonzero elements I would like to sort from smallest to largest, so that the top left element is the largest diagonal and the bottom left element is the smallest. Is there an efficient way to find the permutation matrix that corresponds to whatever operation results?
This can be simplified further by seeking a permutation matrix to permute the rows of a column vector in such a way that they are sorted by magnitude, but I still don't know of a good solution.