X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/3bc643e943293ff1a352ca554797a274f2bc91ae..9d044000ae16fbd76fa9e905ed4fd04a0260ca68:/src/lib.rs?ds=sidebyside diff --git a/src/lib.rs b/src/lib.rs index 3002692..fbafcb1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -137,7 +137,7 @@ fn column_counts(rows: &[RowInput]) -> Vec<(usize, String)> { .into_iter() .map(|(col, n)| (n, col)) .collect(); - counts.sort(); + counts.sort_unstable_by(|(an, acol), (bn, bcol)| bn.cmp(an).then(acol.cmp(bcol))); counts } fn column_order(rows: &[RowInput]) -> Vec { @@ -353,7 +353,7 @@ mod tests { .collect::, _>>() .unwrap() ), - vec![(1, String::from("bar")), (2, String::from("baz"))] + vec![(2, String::from("baz")), (1, String::from("bar"))] ); assert_eq!( column_counts( @@ -361,7 +361,7 @@ mod tests { .collect::, _>>() .unwrap() ), - vec![(1, String::from("bar")), (2, String::from("baz"))] + vec![(2, String::from("baz")), (1, String::from("bar"))] ); assert_eq!( column_counts( @@ -369,7 +369,7 @@ mod tests { .collect::, _>>() .unwrap() ), - vec![(1, String::from("bar")), (2, String::from("baz"))] + vec![(2, String::from("baz")), (1, String::from("bar"))] ); }