Advertisement
ilianrusev

Untitled

Jan 13th, 2022
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2. let sorted = [];
  3.  
  4. arr = arr.sort((a, b) => a - b);
  5. while (arr.length > 0) {
  6.  
  7. sorted.push(arr.shift());
  8. sorted.push(arr.pop());
  9.  
  10. }
  11. return sorted;
  12. }
Advertisement
RAW Paste Data Copied
Advertisement