﻿1
00:00:00,420 --> 00:00:03,540
‫So now let's take a look at insertion sort.

2
00:00:03,750 --> 00:00:05,460
‫So I'm going to bring up an array here.

3
00:00:05,460 --> 00:00:13,080
‫And insertion sort always starts with the second item and then we compare it to the item before it.

4
00:00:13,080 --> 00:00:14,670
‫In this case, the four.

5
00:00:15,180 --> 00:00:22,380
‫If it is less than the item that is before it, we switch them like this.

6
00:00:23,610 --> 00:00:24,870
‫And drop that in there.

7
00:00:25,470 --> 00:00:26,700
‫Then we move to the next item.

8
00:00:26,700 --> 00:00:31,470
‫In this case, the six is not less than four, so that's going to stay put.

9
00:00:32,200 --> 00:00:35,140
‫And now the five is less than the six.

10
00:00:35,170 --> 00:00:36,730
‫We will move that over.

11
00:00:37,060 --> 00:00:39,550
‫And then we'll compare the five to the four.

12
00:00:40,310 --> 00:00:41,900
‫It's not less than the four.

13
00:00:42,170 --> 00:00:44,150
‫So that's the spot where that goes.

14
00:00:44,890 --> 00:00:52,090
‫And now the one is less than the six and the five and the four and finally the two.

15
00:00:53,630 --> 00:00:55,180
‫And we drop that in there.

16
00:00:55,190 --> 00:00:56,750
‫And then one more item.

17
00:00:56,990 --> 00:00:59,930
‫This is less than the six and the five and the four.

18
00:01:01,060 --> 00:01:04,230
‫And we drop that in there and now they are all sorted.

19
00:01:04,240 --> 00:01:05,800
‫So I will colour them green.

20
00:01:06,570 --> 00:01:12,000
‫So in the next video, we're just going to start with an array that looks like this.

21
00:01:12,000 --> 00:01:16,800
‫I'm only going to have two that are out of place so we can go through this a lot faster and we will

22
00:01:16,800 --> 00:01:22,200
‫pick up here and the next video when we code insertion sort.

