function bubbleSort(nums) {
let swapped = false;
let iterations = 0;
do {
swapped = false;
for (let i = 0; i < nums.length - iterations - 1; i++) {
if (nums[i] > nums[i + 1]) {
[nums[i], nums[i + 1]] = [nums[i + 1], nums[i]];
swapped = true;
}
}
iterations++;
} while (swapped);
return nums;
}