According to my understanding, the rows can be sorted in such a way that each column contains the minimum element. If there are 3 columns, we need only 3 minimum numbers to minimize the sum. Hence, i first store the minimum 'm' elements in the multiset. I initialize a variable 'required' which keeps track of the column i want to target at the current moment. Then I traverse the 2-D array, if the element found in 2-D array is one of the minimum elements, I erase it from the multiset and increment required, to taregt the next column; I also check the indexing of the occurrence of the minimum element, if index!=required, i swap the current index element and the required index element.
I hope this made sense, tho I think looking at the code will be better x.