Given a matrix with m rows and n columns, each of which are sorted. How to efficiently sort the entire matrix?
I know a solution which runs in O(m n log(min(m,n)). I
If elements are integers within a certain range k where K=o(mn), we can use count sort with extra space to achieve O(mn), otherwise the mnlog(min(m,n)) is the best we can do.