text: Function to print the sorted array if elements are swapped .
code: function getSortedArray ( arr1 , arr2 , n ) { if ( swapElement ( arr1 , arr2 , n ) ) { for ( let i = 0 ; i < n ; i ++ ) { document . write ( arr1 [ i ] + " " ) ; } } else { document . write ( " " ) ; } }