sort evenArr [ ] in ascending order sort oddArr [ ] in descending order
evenArr . sort ( function ( a , b ) { return a - b ; } ) ; oddArr . sort ( function ( a , b ) { return b - a ; } ) ; let i = 0 ; for ( let j = 0 ; j < evenArr . length ; j ++ ) { arr [ i ++ ] = evenArr [ j ] ; } for ( let j = 0 ; j < oddArr . length ; j ++ ) { arr [ i ++ ] = oddArr [ j ] ; } }