This function uses extractMin ( ) to print elements in sorted order
function printSorted ( mat ) { document . write ( " " ) ; for ( let i = 0 ; i < N * N ; i ++ ) { document . write ( extractMin ( mat ) + " " ) ; } } let mat = [ [ 10 , 20 , 30 , 40 ] , [ 15 , 25 , 35 , 45 ] , [ 27 , 29 , 37 , 48 ] , [ 32 , 33 , 39 , 50 ] ] ; printSorted ( mat ) ;