Skip to content
Sharp

Core Collections · interview question

A bug appears around sorting and grouping. What is the strongest first debugging move?

Multiple choiceMediumchapter-3-curatedpremiumcore-collectionssorting-and-grouping
python
lines = [{"sku": "SKU-2", "qty": 1}, {"sku": "SKU-1", "qty": 4}]
lines.sort(key=lambda row: row["sku"])
print(lines)
Choose one answer
Answer and explanation

Correct answer

A. Trace one concrete example, inspect the state transitions, and compare them to the intended rule before rewriting anything.

Why

That approach is reliable because it creates evidence. Performing extra sorting or grouping without a reason adds cost and cognitive noise.

Test yourself on Core Collections

A free test with instant, explained results. No account needed.

Start free test
All Core Collections questions →