From 57d908f706876463f5fdad93d9e6e611d0f5bbc8 Mon Sep 17 00:00:00 2001 From: eric_cheng Date: Sun, 13 Dec 2020 11:56:21 +0800 Subject: [PATCH] fix(typescript): fix error in typescript implemented insert sort algo --- typescript/11_sorts/simpleSort.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/11_sorts/simpleSort.ts b/typescript/11_sorts/simpleSort.ts index a9118456..2c964406 100644 --- a/typescript/11_sorts/simpleSort.ts +++ b/typescript/11_sorts/simpleSort.ts @@ -42,7 +42,7 @@ class InsertSort implements SortAlgo { let j = i - 1 const temp = array[i] for (; j >= 0; j--) { - if (array[j] > array[j + 1]) { + if (array[j] > temp) { array[j + 1] = array[j] } else { // 这个说明之前的已经排好了,没必要继续比较