text: function to sort each row of the matrix according to the order specified by descending .
code: function sortByRow ( mat , n , descending ) { let temp = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( descending == true ) { let t = i ; for ( let p = 0 ; p < n ; p ++ ) { for ( let j = p + 1 ; j < n ; j ++ ) { if ( mat [ t ] [ p ] < mat [ t ] [ j ] ) { temp = mat [ t ] [ p ] ; mat [ t ] [ p ] = mat [ t ] [ j ] ; mat [ t ] [ j ] = temp ; } } } } else mat [ i ] . sort ( function ( a , b ) { return a - b ; } ) ; } }