Kaynağa Gözat

fix sort on bogus data module

George S. Baugh 4 yıl önce
ebeveyn
işleme
769b7b4e5d
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  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;
 }