Elpida3006

sort

Jun 19th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function jumbleSorting(numbers) {
  2.  
  3.     let sortBigtoSmall = numbers.sort((a, b) => b - a)
  4.     let jumbledNum = [];
  5.  
  6.     while (sortBigtoSmall.length > 0) {
  7.  
  8.         jumbledNum.push(sortBigtoSmall.shift())
  9.  
  10.         jumbledNum.push(sortBigtoSmall.pop())
  11.     }
  12.  
  13.     console.log(jumbledNum.join(' '));
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment