Skip to content

Commit 6b0efed

Browse files
Use toSorted instead of sort
1 parent 2c79ecf commit 6b0efed

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/app/(public)/repos/[language]/_components/repo-card.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { ReportButton } from './report-button';
55

66
const MAX_DESCRIPTION_LENGTH = 100;
77
const MAX_TOPICS_DISPLAY = 3;
8+
const numberFormatter = new Intl.NumberFormat('en-US', {
9+
notation: 'compact',
10+
compactDisplay: 'short'
11+
});
812

913
interface RepoCardProps {
1014
repo: RepoItem;
@@ -17,7 +21,7 @@ export function RepoCard({ repo }: RepoCardProps) {
1721
: repo.description;
1822

1923
// Ensure 'hacktoberfest' topic appears first
20-
const sortedTopics = [...repo.topics].sort((a, b) => {
24+
const sortedTopics = repo.topics.toSorted((a, b) => {
2125
if (a === 'hacktoberfest') return -1;
2226
if (b === 'hacktoberfest') return 1;
2327
return 0;
@@ -26,11 +30,6 @@ export function RepoCard({ repo }: RepoCardProps) {
2630
const displayedTopics = sortedTopics.slice(0, MAX_TOPICS_DISPLAY);
2731
const hasMoreTopics = sortedTopics.length > MAX_TOPICS_DISPLAY;
2832

29-
const numberFormatter = new Intl.NumberFormat('en-US', {
30-
notation: 'compact',
31-
compactDisplay: 'short'
32-
});
33-
3433
return (
3534
<section className="transition duration-300 shadow-sm card bg-hacktoberfest-black ring-1 ring-hacktoberfest-light-pink hover:scale-105 hover:shadow-2xl hover:shadow-hacktoberfest-deep-pink h-96">
3635
<div className="relative p-6 card-body">

0 commit comments

Comments
 (0)