8000 Feature: Sleep Sort with randomize timestamp · KyleSmith0905/Sorting-Algorithm@47c78e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 47c78e4

Browse files
committed
Feature: Sleep Sort with randomize timestamp
1 parent 61fde4b commit 47c78e4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/settings/sortingAlgorithm/sleepSort.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export const algorithm = (arr: IDataPoint[], data: any): [IDataPoint[], any] =>
3232
}
3333

3434
startArray.forEach((ele: IDataPoint, index: number) => {
35+
36+
const timestamp = (Math.random() * Math.pow(data.settings.sortingSpeed / 4, 2)) + ele.data * Math.pow(data.timesSorted + 1, 2) * (data.settings.sortingSpeed / 4);
37+
3538
window.setTimeout(() => {
3639
data.actionPoint = ele;
3740
data.highlight.push(index);
@@ -46,7 +49,7 @@ export const algorithm = (arr: IDataPoint[], data: any): [IDataPoint[], any] =>
4649
data.isSorting = false;
4750
}, 10);
4851
}
49-
}, ele.data * Math.pow(data.timesSorted + 1, 2) * (data.settings.sortingSpeed / 4));
52+
}, timestamp);
5053
});
5154
}
5255
else {

0 commit comments

Comments
 (0)
0