aboutsummaryrefslogtreecommitdiff
path: root/src/utils/array.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/array.ts')
-rw-r--r--src/utils/array.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils/array.ts b/src/utils/array.ts
new file mode 100644
index 0000000..15b3506
--- /dev/null
+++ b/src/utils/array.ts
@@ -0,0 +1,7 @@
+export { byOrder };
+
+function byOrder({ order }: { order: 'asc' | 'desc' | null | undefined }) {
+ return (a: string, b: string) => {
+ return order === 'asc' ? a.localeCompare(b) : b.localeCompare(a);
+ };
+}