🧮Sorting Algorithm
Also known as Sort, Sorting
Steps that put a list in order, like small to big or A to Z.
Think of it like
Think of it like putting cards in order. There are many ways, and some are much faster.
Example
Emma sorts 5, 2, 9, 1 with Python's sorted and gets 1, 2, 5, 9. For a million items it still takes under a second.
Why it matters
Sorted data is far faster to search and easier to read. Sorting is one of the most common jobs code does.
Definition
Example code
python
>>> sorted([5, 2, 9, 1])
[1, 2, 5, 9]Common mistake
Key takeaways
- 1Puts items in order. By any rule you choose.
- 2Many kinds. Speed and memory differ.
- 3Use the built-in. For real code.