소스 검색

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;
 }