Przeglądaj źródła

fix sort on bogus data module

George S. Baugh 4 lat temu
rodzic
commit
769b7b4e5d
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      lib/Trog/Data/DUMMY.pm

+ 4 - 0
lib/Trog/Data/DUMMY.pm

@@ -27,6 +27,10 @@ sub read ($self, $query={}) {
     confess "Can't find datastore!" unless -f $datastore;
     my $slurped = File::Slurper::read_text($datastore);
     $posts = JSON::MaybeXS::decode_json($slurped);
+
+    # Sort everything by date DESC
+    @$posts = sort { $b->{created} <=> $a->{created} } @$posts;
+
     return $posts;
 }