From d664df8cb4fea0aad54d2e693f01684cec0590f9 Mon Sep 17 00:00:00 2001 From: Hashem Date: Mon, 29 Mar 2021 15:58:37 +0400 Subject: [PATCH] Update README.markdown `sort()` is in place sort. in reveres `sorted()` returns a sorted copy of the original array --- Insertion Sort/README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Insertion Sort/README.markdown b/Insertion Sort/README.markdown index 8c2a5c1a0..1c41aa91d 100644 --- a/Insertion Sort/README.markdown +++ b/Insertion Sort/README.markdown @@ -114,7 +114,7 @@ insertionSort(list) Here is how the code works. -1. Make a copy of the array. This is necessary because we cannot modify the contents of the `array` parameter directly. Like Swift's own `sort()`, the `insertionSort()` function will return a sorted *copy* of the original array. +1. Make a copy of the array. This is necessary because we cannot modify the contents of the `array` parameter directly. Like Swift's own `sorted()`, the `insertionSort()` function will return a sorted *copy* of the original array. 2. There are two loops inside this function. The outer loop looks at each of the elements in the array in turn; this is what picks the top-most number from the pile. The variable `x` is the index of where the sorted portion ends and the pile begins (the position of the `|` bar). Remember, at any given moment the beginning of the array -- from index 0 up to `x` -- is always sorted. The rest, from index `x` until the last element, is the unsorted pile.