A little room to wonder
Data Tables & Sorting
Keep related values together while ordering records, and define what happens when sorting keys tie.
Why can sorting one column by itself damage a table?

A row is a related record
A simple table can store one record per row and one attribute per column. In an invented reading list, a row might contain a card ID, title and page count. The heading tells you what a value represents; a number without its heading can be ambiguous.
If you sort only the page-count column while leaving titles in place, the values no longer describe the original records. Ordering should move whole rows together unless the task explicitly creates a new, separate summary. Neat columns are not evidence that relationships have been preserved.
Choose a key and direction
A sorting key is the attribute used for comparison. Ascending page count differs from alphabetical title order. Numeric comparison also differs from text comparison: the numeral strings 10 and 2 may be ordered differently from the numbers 10 and 2, depending on the chosen rule.
A secondary key resolves a tie in the first key. Another option is a stable sort, which preserves the original relative order among equal-key records. That is a property to specify or check, not something every imaginable sorting procedure automatically provides.
Worked example: keep the cards intact
Three fictional records are A: Cloud Map, 12 pages; B: Paper Robot, 8 pages; C: Leaf Sketch, 12 pages. Sorting by ascending page count puts B first. If the second key is alphabetical title, A comes before C, giving B, A, C.
If instead a stable page-count sort starts from the order C, B, A, the tied 12-page cards remain C before A, giving B, C, A. Neither result changes any card’s page count. The difference comes from the stated tie rule, not from one sort being mysteriously wrong.
Missing data need a visible rule
An empty page-count field is not necessarily zero. Decide whether unknown values go last, are excluded from a particular calculation or remain in an explicitly labelled group. Quietly replacing blanks with 0 changes the information.
Use an ID to check that all records survive and keep an original copy of the supplied fictional table for comparison. Sorting changes arrangement, not truth. A well-ordered table can still contain an inaccurate value, so validation and ordering remain separate tasks.
Only if you feel like trying
Sort three fictional records two ways
- Write each supplied record as one row or one drawn card.
- Apply page-count plus title order, then apply stable page-count order from C, B, A.
- Add a fourth record with an unknown page count and explain your missing-value rule.
Optional. Use paper or talk through the supplied fictional example. No purchase, personal information, account, public sharing or practical experiment is needed.
Look at the sources.
These references offer further reading on the ideas here. Check who published them, what they support and what you would ask next.
- Python Software FoundationSorting Techniques
Research checked 1 November 2026. External pages have their own content and privacy practices.
Where could this connect?
These are editorial links between subjects. You choose which, if any, to follow.
Categories & Counterexamples
A tie is a useful counterexample to the assumption that one key always gives a unique order.
Follow this connectionComputing
Computing represents records and compares explicit keys without losing their relationships.
Follow this connectionStatistics & Data
A sorted dataset still needs accurate units, missing-value rules and checks on its meaning.
Follow this connection