Skip to content

Commit adbd7eb

Browse files
committed
Sort posts as YYYY-MM-DD-TITLE, not YYYY-M-D-TITLE
Previously all December, November and October posts were buried below February, because `2019/2/1` (Feb 1) is lexicographically above (in front of?) `2019/10/1` (Oct 1). This is not how mother nature intended it in ISO8601: * https://en.wikipedia.org/wiki/ISO_8601 Let's correct this mistake by sorting dates with zero prefixed month and day numbers to make all dates of fixed size. Among other things, this puts Rust 1.40 (released `2019-12-19`) as the version newer than Rust 1.38 (released `2019-09-26`), which is now linked as the latest version on rust-lang.org, despite link saying it's Rust 1.40. Closes #500
1 parent 29b16a2 commit adbd7eb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/blogs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ impl Blog {
5959
}
6060
}
6161

62-
posts.sort_by_key(|post| post.url.clone());
62+
posts.sort_by_key(|post| {
63+
format!(
64+
"{}-{:02}-{:02}-{}",
65+
post.year, post.month, post.day, post.title
66+
)
67+
});
6368
posts.reverse();
6469

6570
// Decide which posts should show the year in the index.

0 commit comments

Comments
 (0)