diff --git a/src/ui/city-autocomplete/CityPickerPopup.tsx b/src/ui/city-autocomplete/CityPickerPopup.tsx index 9a074e0a..5224a4bc 100644 --- a/src/ui/city-autocomplete/CityPickerPopup.tsx +++ b/src/ui/city-autocomplete/CityPickerPopup.tsx @@ -25,7 +25,30 @@ export const CityPickerPopup: FC = ({ onLocate, onClose, }) => { - const regions = dictionaries.regions; + // TZ §4.1.9.2: "Россия и СНГ" direction pinned first; other directions + // alphabetical by localized name. `localeCompare` gives locale-aware + // collation; we detect the pinned direction by matching "Россия" / + // "Russia" / "CIS" as substrings so minor name variations still match. + const regions = useMemo(() => { + const sorted = [...dictionaries.regions].sort((a, b) => + a.name.localeCompare(b.name), + ); + const isCisName = (s: string): boolean => { + const lower = s.toLowerCase(); + return ( + lower.includes("россия") || + lower.includes("russia") || + lower.includes("снг") || + lower.includes("cis") + ); + }; + const cisIdx = sorted.findIndex((r) => isCisName(r.name)); + if (cisIdx > 0) { + const [cis] = sorted.splice(cisIdx, 1); + if (cis) sorted.unshift(cis); + } + return sorted; + }, [dictionaries.regions]); const [activeRegionId, setActiveRegionId] = useState( regions[0]?.id ?? 0, );