Skip to content

Commit 293aa1c

Browse files
committedOct 4, 2024·
Merge branch 'develop'
2 parents c6e9f5d + 0979981 commit 293aa1c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎src/pages/Sponsor/patron.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ const PatronContainer = styled.div`
6868
}
6969
7070
@media only screen and (max-width: 809px) {
71+
width: 75%;
72+
7173
p {
7274
font-size: 0.8rem;
7375
font-weight: bold;

‎src/utils/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,17 @@ export function elapsedBefore(
150150
throw new Error(type);
151151
}
152152
}
153+
154+
export function sortByKey<T extends Record<string, any>>(array: T[], key: keyof T): T[] {
155+
return array.sort((a, b) => {
156+
const av = a[key] as any;
157+
const bv = b[key] as any;
158+
159+
if (av == null) return -1;
160+
if (bv == null) return 1;
161+
if (typeof av === "number" && typeof bv === "number") return av - bv;
162+
if (av instanceof Date && bv instanceof Date) return av.getTime() - bv.getTime();
163+
164+
return av === bv ? 0 : av > bv ? 1 : -1;
165+
});
166+
}

0 commit comments

Comments
 (0)
Please sign in to comment.