From d2709c4d32b6f07a1e30b4300a8ec17c67229a27 Mon Sep 17 00:00:00 2001 From: arielkruger1989 Date: Wed, 4 Aug 2021 23:49:51 +0100 Subject: [PATCH] Fix call to sort function from javascript by default if not passed a comparator function the sort function will sort items as string https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort. So giving the number comparator function here so it sorts correctly. --- specs/radix-sort/radix-sort.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/radix-sort/radix-sort.test.js b/specs/radix-sort/radix-sort.test.js index b32ae006..27d63d1b 100644 --- a/specs/radix-sort/radix-sort.test.js +++ b/specs/radix-sort/radix-sort.test.js @@ -71,6 +71,6 @@ describe.skip("radix sort", function () { .fill() .map(() => Math.floor(Math.random() * 500000)); const ans = radixSort(nums); - expect(ans).toEqual(nums.sort()); + expect(ans).toEqual(nums.sort((a, b) => a - b)); }); });