MCPcopy Create free account
hub / github.com/code100x/daily-code / sortTracks

Function sortTracks

apps/web/components/Tracks.tsx:69–83  ·  view source on GitHub ↗
(sortBy: string)

Source from the content-addressed store, hash-verified

67 };
68
69 const sortTracks = (sortBy: string) => {
70 setLoading(true);
71 let sortedTracks = [...filteredTracks];
72 if (sortBy === "ascending") {
73 sortedTracks.sort((a, b) => a.title.localeCompare(b.title));
74 } else if (sortBy === "descending") {
75 sortedTracks.sort((a, b) => b.title.localeCompare(a.title));
76 } else if (sortBy === "new") {
77 sortedTracks.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
78 } else if (sortBy === "old") {
79 sortedTracks.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
80 }
81 setFilteredTracks(sortedTracks);
82 setLoading(false);
83 };
84
85 const handleCohortSelection = (cohort: number) => {
86 setSelectedCohort((prevCohort) => (prevCohort === cohort ? null : cohort));

Callers 1

TracksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected