比sort()性能更好的原生js代码实现数组从小到大排序

    nums = [1,2,4,1,34,6,-1,2]
    for(let i = nums.length - 1; i > 0; i--) {
        let maxIdx = i;
        for(let j = 0; j < i; j++) {
            if(nums[maxIdx] < nums[j]) maxIdx = j;
        }
        if(maxIdx !== i) {
            let temp = nums[maxIdx];
            nums[maxIdx] = nums[i];
            nums[i] = temp;
        }
    }
原文地址:https://www.cnblogs.com/hrlin/p/9726271.html