I\'m looking for some pointers here as I don\'t quite know where to start researching this one.
I have a 2D matrix with 0 or 1 in each cell, such as:
1
Treat rows as binary numbers, with the leftmost column as the most significant bit, and sort them in descending order, top to bottom
Treat the columns as binary numbers with the bottommost row as the most significant bit and sort them in ascending order, left to right.
Repeat until you reach a fixed point. Proof that the algorithm terminates left as an excercise for the reader.