diff --git a/assets/static/js/modules/map-manager.js b/assets/static/js/modules/map-manager.js index e3438e8..3149e51 100644 --- a/assets/static/js/modules/map-manager.js +++ b/assets/static/js/modules/map-manager.js @@ -199,7 +199,12 @@ export class MapManager { legend.innerHTML = ''; - for (const [id, source] of this.sourcesData) { + // Sort sources alphabetically by name + const sortedSources = Array.from(this.sourcesData.values()).sort((a, b) => + a.name.localeCompare(b.name) + ); + + for (const source of sortedSources) { const item = document.createElement('div'); item.className = 'legend-item'; item.innerHTML = ` diff --git a/assets/static/js/modules/ui-manager.js b/assets/static/js/modules/ui-manager.js index 8db8301..9bb8618 100644 --- a/assets/static/js/modules/ui-manager.js +++ b/assets/static/js/modules/ui-manager.js @@ -226,8 +226,12 @@ export class UIManager { // Clear options except "All Sources" select.innerHTML = ''; - // Add source options - for (const [id, source] of this.sourcesData) { + // Sort sources alphabetically by name and add options + const sortedSources = Array.from(this.sourcesData.entries()).sort((a, b) => + a[1].name.localeCompare(b[1].name) + ); + + for (const [id, source] of sortedSources) { const option = document.createElement('option'); option.value = id; option.textContent = source.name;