> For the complete documentation index, see [llms.txt](https://xjliang.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xjliang.gitbook.io/notes/02_ds_algo/algo/sort.md).

# Sort

* 深刻的理解多路快排。第 75 题。
* 链表的排序，插入排序(第 147 题)和归并排序(第 148 题)
* 桶排序和基数排序。第 164 题。
* "摆动排序"。第 324 题。
* 两两不相邻的排序。第 767 题，第 1054 题。
* "饼子排序"。第 969 题。

|      No.     | Title                                                   | Solution |    Difficulty    |  TimeComplexity | SpaceComplexity |    Favorite   |   Acceptance  |
| :----------: | ------------------------------------------------------- | :------: | :--------------: | :-------------: | :-------------: | :-----------: | :-----------: |
|     0056     | Merge Intervals                                         |          |      Medium      |    O(n log n)   |     O(log n)    |               |     40.7%     |
|     0057     | Insert Interval                                         |          |      Medium      |       O(n)      |       O(1)      |               |     34.9%     |
|     0075     | Sort Colors                                             |          |      Medium      |       O(n)      |       O(1)      |       ❤️      |     49.0%     |
|     0147     | Insertion Sort List                                     |          |      Medium      |       O(n)      |       O(1)      |       ❤️      |     44.2%     |
|     0148     | Sort List                                               |          |      Medium      |    O(n log n)   |     O(log n)    |       ❤️      |     45.9%     |
|     0164     | Maximum Gap                                             |          |       Hard       |    O(n log n)   |     O(log n)    |       ❤️      |     36.6%     |
|     0179     | Largest Number                                          |          |      Medium      |    O(n log n)   |     O(log n)    |       ❤️      |     30.5%     |
|     0220     | Contains Duplicate III                                  |          |      Medium      |    O(n log n)   |       O(1)      |       ❤️      |     21.3%     |
|     0242     | Valid Anagram                                           |          |       Easy       |       O(n)      |       O(n)      |               |     58.0%     |
|     0274     | H-Index                                                 |          |      Medium      |       O(n)      |       O(n)      |               |     36.3%     |
|     0315     | Count of Smaller Numbers After Self                     |          |       Hard       |                 |                 |               |     42.6%     |
|     0324     | Wiggle Sort II                                          |          |      Medium      |       O(n)      |       O(n)      |       ❤️      |     30.6%     |
|     0327     | Count of Range Sum                                      |          |       Hard       |                 |                 |               |     35.9%     |
|     0349     | Intersection of Two Arrays                              |          |       Easy       |       O(n)      |       O(n)      |               |     64.5%     |
|     0350     | Intersection of Two Arrays II                           |          |       Easy       |       O(n)      |       O(n)      |               |     51.9%     |
|     0493     | Reverse Pairs                                           |          |       Hard       |                 |                 |               |     26.6%     |
|     0524     | Longest Word in Dictionary through Deleting             |          |      Medium      |       O(n)      |       O(1)      |               |     48.9%     |
|     0710     | Random Pick with Blacklist                              |          |       Hard       |       O(n)      |       O(n)      |               |     32.6%     |
|     0767     | Reorganize String                                       |          |      Medium      |    O(n log n)   |     O(log n)    |       ❤️      |     49.9%     |
|     0853     | Car Fleet                                               |          |      Medium      |    O(n log n)   |     O(log n)    |               |     43.6%     |
|     0922     | Sort Array By Parity II                                 |          |       Easy       |       O(n)      |       O(1)      |               |     70.4%     |
|     0969     | Pancake Sorting                                         |          |      Medium      |    O(n log n)   |     O(log n)    |       ❤️      |     68.6%     |
|     0973     | K Closest Points to Origin                              |          |      Medium      |    O(n log n)   |     O(log n)    |               |     64.5%     |
|     0976     | Largest Perimeter Triangle                              |          |       Easy       |    O(n log n)   |     O(log n)    |               |     58.5%     |
|     1030     | Matrix Cells in Distance Order                          |          |       Easy       |      O(n^2)     |       O(1)      |               |     66.9%     |
|     1054     | Distant Barcodes                                        |          |      Medium      |    O(n log n)   |     O(log n)    |       ❤️      |     44.2%     |
|     1122     | Relative Sort Array                                     |          |       Easy       |                 |                 |               |     67.9%     |
|     1235     | Maximum Profit in Job Scheduling                        |          |       Hard       |                 |                 |               |     47.0%     |
|     1305     | All Elements in Two Binary Search Trees                 |          |      Medium      |                 |                 |               |     77.8%     |
|     1329     | Sort the Matrix Diagonally                              |          |      Medium      |                 |                 |               |     81.8%     |
|     1640     | Check Array Formation Through Concatenation             |          |       Easy       |                 |                 |               |     60.7%     |
|     1647     | Minimum Deletions to Make Character Frequencies Unique  |          |      Medium      |                 |                 |               |     53.9%     |
|     1648     | Sell Diminishing-Valued Colored Balls                   |          |      Medium      |                 |                 |               |     30.9%     |
| ------------ | ------------------------------------------------------- |  ------- | ---------------- | --------------- |  -------------  | ------------- | ------------- |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xjliang.gitbook.io/notes/02_ds_algo/algo/sort.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
