Advertisement
Coldsewoo

Untitled

Jun 27th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const sortArray = (array) => {
  2.   const arr = array.slice();
  3.   const oddArrSorted = arr.filter(e => e & 1).sort((a, b) => a - b);
  4.   const evenArrSorted = arr.filter(e => !(e & 1)).sort((a, b) => b - a);
  5.   return arr.map(e => (e & 1 ? oddArrSorted.shift() : evenArrSorted.shift()));
  6. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement