From f961932de01651b96c67337de1275d044f4a2191 Mon Sep 17 00:00:00 2001 From: biaji <2725285+biaji@users.noreply.github.com> Date: Tue, 16 Jul 2019 14:18:13 +0800 Subject: [PATCH 1/2] Update solution.md --- 1-js/05-data-types/05-array-methods/9-shuffle/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/05-array-methods/9-shuffle/solution.md b/1-js/05-data-types/05-array-methods/9-shuffle/solution.md index fb864b691e..1eb0db76af 100644 --- a/1-js/05-data-types/05-array-methods/9-shuffle/solution.md +++ b/1-js/05-data-types/05-array-methods/9-shuffle/solution.md @@ -62,7 +62,7 @@ JavaScript 引擎的代码结果可能会有所不同,但我们已经可以看 为什么它不起作用?一般来说,`sort` 是一个“黑匣子”:我们向其中抛出一个数组和一个比较函数,并期望数组被排序。由于比较的完全随机性,黑盒子变得复杂,它究竟发生了什么取决于引擎之间的具体实现。 -还有其他很好的方法来完成这项任务。例如,有一个很好的算法叫做 [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle). The idea is to walk the array in the reverse order and swap each element with a random one before it: +还有其他很好的方法来完成这项任务。例如,有一个很好的算法叫做 [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle). 其思路是:逆向遍历数组,并将每个子项与前面随机的一个子项互相交换: ```js function shuffle(array) { From 1700e5188a44fc796cef4a8d5f7394836f76d787 Mon Sep 17 00:00:00 2001 From: LycheeEng Date: Tue, 16 Jul 2019 14:26:06 +0800 Subject: [PATCH 2/2] Update solution.md --- 1-js/05-data-types/05-array-methods/9-shuffle/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/05-array-methods/9-shuffle/solution.md b/1-js/05-data-types/05-array-methods/9-shuffle/solution.md index 1eb0db76af..c15775ab13 100644 --- a/1-js/05-data-types/05-array-methods/9-shuffle/solution.md +++ b/1-js/05-data-types/05-array-methods/9-shuffle/solution.md @@ -62,7 +62,7 @@ JavaScript 引擎的代码结果可能会有所不同,但我们已经可以看 为什么它不起作用?一般来说,`sort` 是一个“黑匣子”:我们向其中抛出一个数组和一个比较函数,并期望数组被排序。由于比较的完全随机性,黑盒子变得复杂,它究竟发生了什么取决于引擎之间的具体实现。 -还有其他很好的方法来完成这项任务。例如,有一个很好的算法叫做 [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle). 其思路是:逆向遍历数组,并将每个子项与前面随机的一个子项互相交换: +还有其他很好的方法来完成这项任务。例如,有一个很好的算法叫做 [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)。其思路是:逆向遍历数组,并将每个子项与前面随机的一个子项互相交换: ```js function shuffle(array) {