Bubble sort algorithm JavaScript [closed]
问题 Please can you tell me what is wrong to this implementation of bubble sort algorithm in JavaScript? for (var i=1; i<records.length; i++){ for (var j=records.length; j<1; j--){ if (parseInt(records[i-1]) < parseInt(records[i])){ var temp = records[i-1]; records[i-1] = records[i] records[i] = temp; } } } 回答1: Couple of codes for bubble sort bubblesort should not be used for larger arrays, can be used for smaller ones for its simplicity. Method 1 var a = [33, 103, 3, 726, 200, 984, 198, 764, 9];