瀏覽代碼

fix sort on bogus data module

George S. Baugh 4 年之前
父節點
當前提交
769b7b4e5d
共有 1 個文件被更改,包括 4 次插入0 次删除
  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;
 }