text: function to sort each row of the matrix according to the order specified by ascending .
code: function sortByRow ( & $ mat , $ n , $ ascending ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ ascending ) sort ( $ mat [ $ i ] ) ; else rsort ( $ mat [ $ i ] ) ; } }