Update bucketSort.md

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-12-29 12:22:44 +02:00
committed by GitHub
parent 443b97a4ca
commit b8f032cc28

View File

@ -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)], []);
};
```