js
\n/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar sortArrayByParityII = function(nums) {\nlet res = [];\nnums = nums.sort()\n\n\nlet odd = [];\n
```\n/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar sortArrayByParityII = function(nums) {\nlet res = [];\nnums = nums.sort()\n\n\nlet odd = [];\nlet even = [];\nfor (let i = 0; i < nums.length; i++) {\n  if(nums[i] % 2 === 0) odd.push(nums[i]);\n  else {\n    even.push(nums[i])\n  }  \n}\nfor (let i = 0; i < nums.length; i++) {\n  if(i % 2 === 0)\n    res.push(odd.pop())\n  else  res.push(even.pop())\n}\nreturn res\n};\n```\n
['JavaScript']