kalinx

numngfr

Sep 17th, 2021
713
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sortNums(nums) {
  2.     nums = nums.sort((a, b) => a - b);
  3.     let result = []
  4.     while (nums.length > 0) {
  5.         result.push(nums.shift());
  6.         if (nums.length == 0) break;
  7.         result.push(nums.pop());
  8.     }
  9.     return result;
  10. }
  11.  
RAW Paste Data