Now arr1 [ ] is smaller Sort the first array and print its elements ( these two steps can be swapped as order in output is not important )
arr1 . sort ( ( a , b ) => a - b ) ; for ( let i = 0 ; i < m ; i ++ ) document . write ( arr1 [ i ] + " " ) ;