Skip to content
Snippets Groups Projects
Commit 2461be97 authored by Pierre Ecarlat's avatar Pierre Ecarlat
Browse files

Changed alphabetical order for sorting

parent c908bedd
No related branches found
No related tags found
1 merge request!450feat: New commune 'Tout Lyon'
Pipeline #115113 passed
......@@ -135,19 +135,20 @@ export class UserRegistryService {
}
});
// Convert Set to Array and sort by commune name
const formattedCommunes = Array.from(communesSet)
.map((key) => {
const [commune, inseeCode] = key.split('|');
return { commune, inseeCode };
})
.sort((a, b) => a.commune.localeCompare(b.commune));
// Convert Set to Array
const formattedCommunes = Array.from(communesSet).map((key) => {
const [commune, inseeCode] = key.split('|');
return { commune, inseeCode };
});
// An extra commune should be added (Lyon, any district)
if (formattedCommunes.some((item) => item.commune.startsWith('Lyon '))) {
formattedCommunes.push({ commune: 'Tout lyon', inseeCode: '69123' });
formattedCommunes.push({ commune: 'Lyon', inseeCode: '69123' });
}
// Sort by commune name
formattedCommunes.sort((a, b) => a.commune.localeCompare(b.commune));
return formattedCommunes;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment