You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notes/sorting.md
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -30,14 +30,16 @@ Consider the following pairs of characters and their indices:
30
30
When we sort these pairs alphabetically by character using a stable sorting method, pairs with the same character retain their original order in terms of indices.
31
31
32
32
1. Sort the character 'A':
33
-
```
34
-
[A0] [A3] [C1] [B2] [B4]
35
-
```
33
+
34
+
```
35
+
[A0] [A3] [C1] [B2] [B4]
36
+
```
36
37
37
38
2. Next, sort the character 'B', retaining the original order of indices:
38
-
```
39
-
[A0] [A3] [B2] [B4] [C1]
40
-
```
39
+
40
+
```
41
+
[A0] [A3] [B2] [B4] [C1]
42
+
```
41
43
42
44
So, the stable sorted sequence is:
43
45
@@ -50,14 +52,16 @@ So, the stable sorted sequence is:
50
52
When we sort these pairs alphabetically by character using an unstable sorting method, pairs with the same character may not retain their original order in terms of indices.
51
53
52
54
1. Sort the character 'A':
53
-
```
54
-
[A3] [A0] [C1] [B2] [B4]
55
-
```
55
+
56
+
```
57
+
[A3] [A0] [C1] [B2] [B4]
58
+
```
56
59
57
60
2. Next, sort the character 'B', without retaining the original order of indices:
0 commit comments