mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Upgrade packages.
This commit is contained in:
@@ -14,8 +14,8 @@ export default class InsertionSort extends Sort {
|
||||
// Go and check if previous elements and greater then current one.
|
||||
// If this is the case then swap that elements.
|
||||
while (
|
||||
array[currentIndex - 1] !== undefined &&
|
||||
this.comparator.lessThan(array[currentIndex], array[currentIndex - 1])
|
||||
array[currentIndex - 1] !== undefined
|
||||
&& this.comparator.lessThan(array[currentIndex], array[currentIndex - 1])
|
||||
) {
|
||||
// Call visiting callback.
|
||||
this.callbacks.visitingCallback(array[currentIndex - 1]);
|
||||
|
||||
@@ -18,9 +18,9 @@ export default class RadixSort extends Sort {
|
||||
const numPasses = this.determineNumPasses(sortedArray);
|
||||
|
||||
for (let currentIndex = 0; currentIndex < numPasses; currentIndex += 1) {
|
||||
const buckets = isArrayOfNumbers ?
|
||||
this.placeElementsInNumberBuckets(sortedArray, currentIndex) :
|
||||
this.placeElementsInCharacterBuckets(sortedArray, currentIndex, numPasses);
|
||||
const buckets = isArrayOfNumbers
|
||||
? this.placeElementsInNumberBuckets(sortedArray, currentIndex)
|
||||
: this.placeElementsInCharacterBuckets(sortedArray, currentIndex, numPasses);
|
||||
|
||||
// Flatten buckets into sortedArray, and repeat at next index
|
||||
sortedArray = buckets.reduce((acc, val) => {
|
||||
|
||||
Reference in New Issue
Block a user