Sort aggregated rows by `sort_keys = [(column, ascending), ...]`. Each row is a `serde_json::Value::Object`; for every key, the extracted value is converted to a comparable form (numbers compared numerically, strings lexically, nulls last). Keys missing from a row sort as null. The sort is stable to preserve relative order of equal-key rows.
(rows: &mut [serde_json::Value], sort_keys: &[(String, bool)])
| 117 | /// row sort as null. The sort is stable to preserve relative order of |
| 118 | /// equal-key rows. |
| 119 | fn sort_aggregated_rows(rows: &mut [serde_json::Value], sort_keys: &[(String, bool)]) { |
| 120 | if sort_keys.is_empty() { |
| 121 | return; |
| 122 | } |
| 123 | rows.sort_by(|a, b| { |
| 124 | for (column, ascending) in sort_keys { |
| 125 | let av = a.get(column); |
| 126 | let bv = b.get(column); |
| 127 | let ord = compare_json_values(av, bv); |
| 128 | if ord != std::cmp::Ordering::Equal { |
| 129 | return if *ascending { ord } else { ord.reverse() }; |
| 130 | } |
| 131 | } |
| 132 | std::cmp::Ordering::Equal |
| 133 | }); |
| 134 | } |
| 135 | |
| 136 | /// Compare two `Option<&serde_json::Value>` for sort. Nulls / absent |
| 137 | /// keys sort last; numbers compare numerically; everything else falls |
no test coverage detected