Everything Is Important — Until You Sort It
Everything Is Important — Until You Sort It
A tale of overwhelm, order, and priority — where a scroll archive teaches Selection Sort, Insertion Sort, and the power of putting things in the right order.
Characters: Arjun, Guru Bodhi, Archive Keeper · Arc: Beginner · Pattern: Sorting (Selection & Insertion)
📜 Sutra of Overwhelm — The Hall of a Thousand Scrolls
Deep beneath the Gurukul, Arjun followed Guru Bodhi into a long stone corridor. Lanterns flickered. Dust shimmered in the air. The hallway opened into a vast hall lined with shelves from floor to ceiling.
Every shelf was crammed with scrolls — some glowing faintly, some cracked with age, some tied in golden thread, others barely held together. None of them were labeled. None of them were in order.
Arjun’s stomach dropped. “This feels like my mind,” he whispered. “Courses I want to take, books I want to read, side projects, ideas, tasks for work… all mixed together.”
A thin figure emerged from between shelves: the Archive Keeper, robes ink-stained, eyes sharp and tired.
Arjun looked from shelf to shelf. “Everything here seems important,” he said. “Where do I even start?”
🧭 Real-Life Mirror — Your Brain’s Scroll Archive
You already live inside an archive like this:
- A to-do list with urgent work tasks mixed with “someday” side projects.
- Tabs open for deep papers, lightweight blogs, random videos, and memes — all in one bar.
- Bookmarks: career guides, recipes, crypto threads, and ML papers in the same folder.
- Backlog tickets: tiny bug fixes and huge refactors fighting for attention equally.
When everything looks equally important, your brain treats all scrolls the same — and you freeze. The problem is not that you lack effort. It’s that you lack order.
Sorting is not just tidying. Sorting is deciding what belongs where — and what matters now.
📜 Sutra of Naming — What Are We Really Doing?
Arjun picked up a random scroll. “If I start here, I might regret it,” he muttered. “What if there’s something more important on the next shelf? Or the next?”
He pointed to the shelves. “These scrolls hold knowledge. But without order, even wisdom is wasted.”
The Archive Keeper nodded. “We are not asking you to read everything. We ask you to decide: What comes first? What comes next?”
Arjun frowned. “So I’m not solving a reading problem. I’m solving a sorting problem.”
Guru Bodhi and the Archive Keeper, searching for order within endless shelves.
📜 Sutra of Two Paths — Selection vs Insertion
The Guru drew a short row of empty spaces on the floor, like slots on a shelf.
Selection Sort — The “Pick the Best for This Spot” Method
Imagine you want the scrolls on the first shelf ordered from easiest to hardest. You first scan all scrolls and pick the easiest one — that becomes position 1.
Then you scan the remaining scrolls and pick the easiest among them — that becomes position 2. You repeat this until every position has the best remaining candidate.
This is like organizing candidates for a shortlist: each round, pick the current best and fix it in place.
Insertion Sort — The “Insert into a Growing Sorted Shelf” Method
Now imagine the first shelf is already sorted. You pick up a new scroll. You walk along the shelf, find where it belongs, slide the others slightly, and insert it there.
You keep doing this: each new scroll is inserted into the already sorted part.
This is closer to how humans sort: “Let me put this one in the right spot among what I’ve already arranged.”
In simple terms: Selection Sort picks the best for each position. Insertion Sort grows a sorted region and inserts new items where they fit.
🧭 Real-World Tasks — Sorting by Urgency and Impact
Arjun unrolled a small scroll listing his day:
- Fix a bug blocking teammates.
- Review a pull request.
- Explore a new machine learning course.
- Refactor an old module “someday”.
- Call his parents.
All of them feel important. But urgency and impact are not the same for each. Sorting tasks means deciding:
- Urgency: How soon does delay start hurting?
- Impact: How much does it matter if this is done well?
You can treat each task like a scroll with two numbers: urgency and impact. Then order them so your next action is not random — it’s sorted.
🧠 The Scroll of Tasks — Sorting by a Key
In code, each task can be a small dictionary with
name,
urgency, and
impact. Assume 1 = high,
3 = low.
tasks = [
{'name': 'Fix blocking bug', 'urgency': 1, 'impact': 3},
{'name': 'Review pull request', 'urgency': 2, 'impact': 2},
{'name': 'Explore ML course', 'urgency': 3, 'impact': 3},
{'name': 'Refactor old module', 'urgency': 3, 'impact': 2},
{'name': 'Call parents', 'urgency': 2, 'impact': 1},
]
# Sort by urgency first, then by impact
tasks_sorted = sorted(
tasks,
key=lambda t: (t['urgency'], t['impact'])
)
for t in tasks_sorted:
print(t['urgency'], t['impact'], '-', t['name'])
Now your “what should I do next?” is not a feeling — it is the first item of a sorted list.
📜 The Scroll of Ordering — Selection & Insertion Sort
To understand how ordering works underneath, Arjun practiced sorting simple lists of numbers — like scroll difficulty levels.
Selection Sort — Pick the Smallest for Each Position
def selection_sort(arr):
"""Sort a list in-place using selection sort (ascending)."""
n = len(arr)
for i in range(n):
min_idx = i
# Find smallest element in the remaining suffix
for j in range(i + 1, n):
if arr[j] < arr[min_idx]:
min_idx = j
# Place that smallest element at position i
arr[i], arr[min_idx] = arr[min_idx], arr[i]
return arr
Selection sort always scans the remaining region to find the smallest element for the current slot. Simple, but it compares a lot.
Insertion Sort — Insert into the Sorted Prefix
def insertion_sort(arr):
"""Sort a list in-place using insertion sort (ascending)."""
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
# Shift larger elements one position to the right
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j -= 1
# Insert the key into its correct place
arr[j + 1] = key
return arr
Complexity
-
Selection Sort:
O(n²)time, minimal swaps, not stable. -
Insertion Sort:
O(n²)time in worst case, but very fast when the list is almost sorted. -
Both use
O(1)extra space.
Guru: “Selection is like picking the best candidate for each position. Insertion is like updating a ranked list whenever something new appears.”
📜 Sutra of Action — How Arjun Uses Sorting in Real Life
As the day passed, Arjun stopped treating every scroll as equally urgent. He created a small corner of order:
- One shelf for today — scrolls sorted by urgency and impact, like his real task list.
- One shelf for this month — deeper, slower scrolls he’d visit after stabilizing today.
- One chest for someday — ideas worth keeping, but not worth stressing about.
It wasn’t perfect. But it was sorted enough that the next action was obvious.