diff --git a/src/components/search/CatPrezSearchMap.vue b/src/components/search/CatPrezSearchMap.vue
index e162714..fcf14d1 100644
--- a/src/components/search/CatPrezSearchMap.vue
+++ b/src/components/search/CatPrezSearchMap.vue
@@ -8,7 +8,7 @@ import { useApiRequest, useSparqlRequest } from "@/composables/api";
import { useRdfStore } from "@/composables/rdfStore";
import { catalogSpatialSearch, getThemesQuery } from "@/sparqlQueries/catalogSearch";
import { shapeQueryPart } from "@/util/mapSearchHelper"
-import { copyToClipboard } from "@/util/helpers";
+import { copyToClipboard, sortByTitle } from "@/util/helpers";
import MapClient from "@/components/MapClient.vue";
import LoadingMessage from "@/components/LoadingMessage.vue";
import ErrorMessage from "@/components/ErrorMessage.vue";
@@ -137,19 +137,7 @@ async function getCatalogs() {
}
}, namedNode(qnameToIri("a")), namedNode(qnameToIri("dcat:Catalog")), null);
- // sort by title first, then by IRI if no title
- catalogOptions.sort((a, b) => {
- if (a.title && b.title) {
- return a.title.localeCompare(b.title);
- } else if (a.title) {
- return -1;
- } else if (b.title) {
- return 1;
- } else {
- return a.iri.localeCompare(b.iri);
- }
- });
- catalogs.value = catalogOptions;
+ catalogs.value = catalogOptions.sort(sortByTitle);
}
}
diff --git a/src/components/search/SpacePrezSearchMap.vue b/src/components/search/SpacePrezSearchMap.vue
index 018e7ac..cadd4ba 100644
--- a/src/components/search/SpacePrezSearchMap.vue
+++ b/src/components/search/SpacePrezSearchMap.vue
@@ -5,7 +5,7 @@ import { apiBaseUrlConfigKey, mapConfigKey, type MapConfig, type ProfileHeader }
import { useUiStore } from "@/stores/ui";
import { useApiRequest, useConcurrentApiRequests, useSparqlRequest } from "@/composables/api";
import { useRdfStore } from "@/composables/rdfStore";
-import { copyToClipboard } from "@/util/helpers";
+import { copyToClipboard, sortByTitle } from "@/util/helpers";
import { AreaTypes, ShapeTypes, type Coords } from "@/components/MapClient.d";
import { enumToOptions } from "@/util/mapSearchHelper";
import MapClient from "@/components/MapClient.vue";
@@ -215,31 +215,11 @@ async function getDatasets() {
}, subject, namedNode(qnameToIri("rdfs:member")), null);
// sort by title first, then by IRI if no title
- datasetOptions[subject.value].featureCollections.sort((a, b) => {
- if (a.title && b.title) {
- return a.title.localeCompare(b.title);
- } else if (a.title) {
- return -1;
- } else if (b.title) {
- return 1;
- } else {
- return a.iri.localeCompare(b.iri);
- }
- });
+ datasetOptions[subject.value].featureCollections.sort(sortByTitle);
}, namedNode(qnameToIri("a")), namedNode(qnameToIri("dcat:Dataset")), null);
// sort by title first, then by IRI if no title
- datasets.value = Object.values(datasetOptions).sort((a, b) => {
- if (a.title && b.title) {
- return a.title.localeCompare(b.title);
- } else if (a.title) {
- return -1;
- } else if (b.title) {
- return 1;
- } else {
- return a.iri.localeCompare(b.iri);
- }
- });
+ datasets.value = Object.values(datasetOptions).sort(sortByTitle);
}
}
@@ -343,7 +323,7 @@ onMounted(async () => {
Collapse all
-