Skip to content

Commit

Permalink
fix sorting by pushing unparsable dates to bottom (hackclub#2231)
Browse files Browse the repository at this point in the history
* fix sorting by pushing unparsable dates to bottom

* Update gallery.tsx
  • Loading branch information
recursiveforte authored Aug 26, 2024
1 parent df3234d commit ac54001
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pages/gallery/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export default function Gallery({ games, tags }: { games: GameMetadata[], tags:
break;
}
case SortOrder.TUTORIALS_AND_CHRONOLOGICAL: {
games = games.sort((a, b) => Date.parse(b.addedOn) - Date.parse(a.addedOn));
games = games.sort((a, b) =>
isNaN(Date.parse(b.addedOn)) ? -1 : isNaN(Date.parse(a.addedOn)) ? 1 : Date.parse(b.addedOn) - Date.parse(a.addedOn)
);

// put tutorials first
games.sort((a, _) => a.tags.includes("tutorial") ? -1 : 1);
Expand Down

0 comments on commit ac54001

Please sign in to comment.