From 03bbe9cc90b8aa06269c868aab3789af8a576dfe Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Sat, 17 Jun 2017 08:42:18 +0900 Subject: [PATCH] Revert "Reverse order sorting to be desc" This reverts commit 26e119479c70a12b9fe27567f5284a92c3ff03e5. --- CHANGELOG.md | 2 -- src/content/sorting.rs | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4114eea3..c9a78f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,6 @@ - `path` and `permalink` now end with a `/` - Generate table of contents for each page - Add `section` to a page Tera context if there is one -- Reverse `order` sorting to be more intuitive: they are now desc, think of them -as 1st, 2nd in the list - Add `aliases` to pages for when you are changing urls but want to redirect to the new one diff --git a/src/content/sorting.rs b/src/content/sorting.rs index 247f1a9d..68a933c7 100644 --- a/src/content/sorting.rs +++ b/src/content/sorting.rs @@ -38,7 +38,7 @@ pub fn sort_pages(pages: Vec, sort_by: SortBy) -> (Vec, Vec) { cannot_be_sorted.push(page); } } - can_be_sorted.sort_by(|a, b| a.meta.order().cmp(&b.meta.order())); + can_be_sorted.sort_by(|a, b| b.meta.order().cmp(&a.meta.order())); (can_be_sorted, cannot_be_sorted) }, @@ -120,10 +120,10 @@ mod tests { create_page_with_order(1), ]; let (pages, _) = sort_pages(input, SortBy::Order); - // Should be sorted by order - assert_eq!(pages[0].clone().meta.order.unwrap(), 1); + // Should be sorted by date + assert_eq!(pages[0].clone().meta.order.unwrap(), 3); assert_eq!(pages[1].clone().meta.order.unwrap(), 2); - assert_eq!(pages[2].clone().meta.order.unwrap(), 3); + assert_eq!(pages[2].clone().meta.order.unwrap(), 1); } #[test]