https://leetcode.com/problems/sort-even-and-odd-indices-independently/


Runtime: 178 ms, faster than 8.16% of TypeScript online submissions for Sort Even and Odd Indices Independently.

Memory Usage: 48 MB, less than 8.16% of TypeScript online submissions for Sort Even and Odd Indices Independently.


```typescript
function sortEvenOdd(nums: number[]): number[] {
    //8:16
    let odd_list = []
    let even_list = []
    
    for (const [index, value] of nums.entries()) {
        if (index % 2 == 0) {
            even_list.push(value)
        } else {
            odd_list.push(value)
        }
    }
    
    even_list.sort(function(a, b) {
      return a - b;
    });
    
    odd_list.sort(function(a, b) {
      return a - b;
    });
    odd_list.reverse()
    
    let result_list = []
    
    for (const [index, value] of nums.entries()) {
        if (index % 2 == 0) {
            result_list.push(even_list.shift())
        } else {
            result_list.push(odd_list.shift())
        }
    }
    
    return result_list
    //8:18
    //debug until 8:32
    //By default in Javascript, the sort method sorts elements alphabetically. To sort numerically, we need to add a function
};
```

