Driver program
var arr = [ 50 , 40 , 70 , 60 , 90 ] ; var index = [ 3 , 0 , 4 , 1 , 2 ] ; var n = arr . length ; reorder ( arr , index , n ) ; document . write ( " " ) ; document . write ( " " ) ; for ( var i = 0 ; i < n ; i ++ ) document . write ( arr [ i ] + " " ) ; document . write ( " " ) ; document . write ( " " ) ; document . write ( " " ) ; for ( var i = 0 ; i < n ; i ++ ) document . write ( index [ i ] + " " ) ;