Turning a Mapping into Report Rows
A report row can retain the key and value from a mapping while presenting them in an independently chosen order.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Inspect a two-entry export
With west mapped to 4 and east to 7, exporting only 4 and 7 loses region names. Emit each pair and choose a stable column order. Dictionary items provide both fields to the transformation.
Select row order explicitly
If readers need regions alphabetically, sort by the region key. If arrival order is meaningful, preserve the declared source order. Key-based sorting helps decide what a sort actually compares.[1]
Choose row fields and order separately
A frequency map {"z": 8, "m": 12, "a": 8} can become rows sorted by descending count and then ascending label, yielding m, a, z. Iteration order would start with z under the original insertion order. If people compare exports between runs, keep the secondary order stable so equal counts do not create false differences. See dictionary insertion order.
Preserve types while formatting
A report row can carry a numeric count twelve until a serializer formats it. Turning it into text before sorting can make twelve appear before eight under lexical ordering. Include separate, explicitly named columns for labels, counts and optional percentages, then validate the names against the consumers' contract. Test ties, counts below and above ten, and an empty mapping. See lexical and numerical ordering.