Update bucketSort.md
This commit is contained in:
committed by
GitHub
parent
443b97a4ca
commit
b8f032cc28
@ -18,11 +18,9 @@ const bucketSort = (arr, size = 5) => {
|
||||
{ length: Math.floor((max - min) / size) + 1 },
|
||||
() => []
|
||||
);
|
||||
|
||||
arr.forEach(val => {
|
||||
buckets[Math.floor((val - min) / size)].push(val);
|
||||
});
|
||||
|
||||
return buckets.reduce((acc, b) => [...acc, ...b.sort((a, b) => a - b)], []);
|
||||
};
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user