From e6c2a8d9653ffde924632ca2f260c3a8cddc14ed Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 11 Sep 2020 00:15:04 +0200 Subject: viewer: item display order github: resolves #28 --- viewer/src/services/itemSortFn.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 viewer/src/services/itemSortFn.ts (limited to 'viewer/src/services') diff --git a/viewer/src/services/itemSortFn.ts b/viewer/src/services/itemSortFn.ts new file mode 100644 index 0000000..ec9942c --- /dev/null +++ b/viewer/src/services/itemSortFn.ts @@ -0,0 +1,28 @@ +/* ldgallery - A static generator which turns a collection of tagged +-- pictures into a searchable web gallery. +-- +-- Copyright (C) 2019-2020 Guillaume FOUET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Affero General Public License for more details. +-- +-- You should have received a copy of the GNU Affero General Public License +-- along with this program. If not, see . +*/ + +export default class ItemSortFn { + static sortByName(left: Gallery.Item, right: Gallery.Item): number { + return left.title.localeCompare(right.title); + } + + static sortByDateDesc(left: Gallery.Item, right: Gallery.Item): number { + return -left.datetime.localeCompare(right.datetime); // TODO: handle timezones + } +} -- cgit v1.2.3