From a848f676064d4be2f492276af115698f1bd1c35b Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Sun, 17 Sep 2023 05:56:37 +0200 Subject: [PATCH] Fixing attributes wrong ordering. --- lib/BurguillosInfo/Posts.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/BurguillosInfo/Posts.pm b/lib/BurguillosInfo/Posts.pm index 8537961..1222d6b 100644 --- a/lib/BurguillosInfo/Posts.pm +++ b/lib/BurguillosInfo/Posts.pm @@ -186,10 +186,9 @@ sub RetrieveAllPostsForCategory ( $self, $category_name ) { sub shufflePostsIfRequired ( $self, $category, $posts ) { my $pinned_posts = [ sort { $b->{pinned} <=> $b->{pinned} } - grep { exists $_->{pinned} } @$posts + grep { defined $_->{pinned} } @$posts ]; $posts = [ grep { !exists $_->{pinned} } @$posts ]; - $pinned_posts = [ sort { $b <=> $a } @$pinned_posts ]; if ( exists $category->{random} && $category->{random} ) { require List::AllUtils; $posts = [ List::AllUtils::shuffle @$posts ]; @@ -206,7 +205,7 @@ sub RetrieveDirectPostsForCategory ( $self, $category_name ) { } my $posts = $post_by_category->{$category_name}; $posts //= []; - return [@$posts]; + return $self->shufflePostsIfRequired($category, [@$posts]); } sub PreviewOg {