Skip to content

Commit fc57eb3

Browse files
authored
Update sorting.md
1 parent b43eabd commit fc57eb3

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

notes/sorting.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ Consider the following pairs of characters and their indices:
3030
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.
3131

3232
1. Sort the character 'A':
33-
```
34-
[A0] [A3] [C1] [B2] [B4]
35-
```
33+
34+
```
35+
[A0] [A3] [C1] [B2] [B4]
36+
```
3637

3738
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+
```
4143

4244
So, the stable sorted sequence is:
4345

@@ -50,14 +52,16 @@ So, the stable sorted sequence is:
5052
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.
5153

5254
1. Sort the character 'A':
53-
```
54-
[A3] [A0] [C1] [B2] [B4]
55-
```
55+
56+
```
57+
[A3] [A0] [C1] [B2] [B4]
58+
```
5659

5760
2. Next, sort the character 'B', without retaining the original order of indices:
58-
```
59-
[A3] [A0] [B4] [B2] [C1]
60-
```
61+
62+
```
63+
[A3] [A0] [B4] [B2] [C1]
64+
```
6165

6266
So, the unstable sorted sequence is:
6367

0 commit comments

Comments
 (0)