function bucketSort(nums: number[], size: number): void {
const k = Math.floor(nums.length / size);
const buckets: number[][] = Array.from({ length: k }, () => []);
const min = Math.min(...nums);
const range = Math.max(...nums) - min;
if (range === 0) return;
for (const num of nums) {
const i = Math.floor(((num - min) / range) * (k - 1));
buckets[i].push(num);
}
for (const bucket of buckets) {
bucket.sort((a, b) => a - b);
}
let i = 0;
for (const bucket of buckets) {
for (const num of bucket) nums[i++] = num;
}
}