Advertisement
kalinx

numngfr

Sep 17th, 2021
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement