We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a81a2bc commit 3fd9836Copy full SHA for 3fd9836
src/sort/mergeSort.test.ts
@@ -0,0 +1,15 @@
1
+import mergeSort from "./mergeSort";
2
+
3
+describe("Test for Merge Sort", () => {
4
+ test("testing if MS sort random array", () => {
5
+ const nTimes = 100;
6
+ for (let i = 0; i < nTimes; i++) {
7
+ const arr = Array.from({ length: 100 }, () =>
8
+ Math.floor(Math.random() * 1000)
9
+ );
10
+ const sortedArr = mergeSort(arr);
11
+ const jsSortedArr = arr.slice().sort((a, b) => a - b);
12
+ expect(sortedArr).toEqual(jsSortedArr);
13
+ }
14
+ });
15
+});
src/sort/mergeSort.ts
@@ -64,4 +64,4 @@ const mergeSort = (arr: number[]): number[] => {
64
return mergeIdx(mergeSort(left), mergeSort(right));
65
};
66
67
-export = mergeSort;
+export default mergeSort;
0 commit comments