X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/e07fd21f8e0b26c2dbaa3b4b1269b0c0a3c933c6..b62c9b5d5929ddc8f282fc8c44a26b1774f36797:/src/lib.rs diff --git a/src/lib.rs b/src/lib.rs index efdb7d8..fbafcb1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ const HEADER: &str = " th, td { white-space: nowrap; } th { text-align: left; font-weight: normal; } table { border-collapse: collapse } - tr.key > th { height: 8em; vertical-align: bottom; line-height: 1 } + tr.key > th { height: 10em; vertical-align: bottom; line-height: 1 } tr.key > th > div { width: 1em; } tr.key > th > div > div { width: 5em; transform-origin: bottom left; transform: translateX(1em) rotate(-65deg) } td { border: thin solid gray; } @@ -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"))] ); }