diff options
author | Adam T. Carpenter <atc@53hor.net> | 2024-09-14 21:11:51 -0400 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2024-09-14 21:11:51 -0400 |
commit | aad33fee01abe817d82c094f83ffd44ca36c8456 (patch) | |
tree | 9db9740d84f97575775cfe832a69ac2eed7d2078 /src/views | |
parent | 18339f611fd17e1300593edd65adf7604a39ad72 (diff) | |
download | carpentertutoring-aad33fee01abe817d82c094f83ffd44ca36c8456.tar.xz carpentertutoring-aad33fee01abe817d82c094f83ffd44ca36c8456.zip |
feat: reverse sort posts by modify datetime
Diffstat (limited to 'src/views')
-rw-r--r-- | src/views/posts.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/views/posts.rs b/src/views/posts.rs index 2ce69f8..82b5996 100644 --- a/src/views/posts.rs +++ b/src/views/posts.rs @@ -10,8 +10,9 @@ pub struct PostsView<P: Post> { impl<P: Post> PostsView<P> { pub fn with_posts(posts: impl IntoIterator<Item = P>) -> Self { - Self { - posts: posts.into_iter().collect(), - } + let mut posts: Vec<P> = posts.into_iter().collect(); + posts.sort(); + posts.reverse(); + Self { posts } } } |