Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit 603978b

Browse files
committed
Sort by team and name
1 parent 91e8ad0 commit 603978b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

components/search/resultList.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,23 @@ const ResultList = ({
9696
(d) => !isDataProduct(d.result)
9797
)
9898

99+
const sortByTeamAndName = (a: any, b: any) => {
100+
if (a.teamkatalogenURL && b.teamkatalogenURL) {
101+
let comparison = a.teamkatalogenURL.localeCompare(b.teamkatalogenURL);
102+
if (comparison !== 0) return comparison;
103+
} else if (a.teamkatalogenURL) {
104+
return -1; // a comes first if b is undefined
105+
} else if (b.teamkatalogenURL) {
106+
return 1; // b comes first if a is undefined
107+
}
108+
// If teamkatalogenURL is the same or both are undefined, sort by name
109+
return a.name.localeCompare(b.name);
110+
}
111+
112+
dataproducts.sort(sortByTeamAndName)
113+
stories.sort(sortByTeamAndName)
114+
insightProducts.sort(sortByTeamAndName)
115+
99116
return (
100117
<Results>
101118
<Tabs

0 commit comments

Comments
 (0)