From ccdd906e2f167afd8fce1fed7a472e96e853b7f7 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 28 Feb 2024 05:37:02 -0500 Subject: [PATCH] Restore alphabetical sorting to Areas (#19897) --- src/data/ws-area_registry.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/data/ws-area_registry.ts b/src/data/ws-area_registry.ts index 43e3d1f13f35..550b9a5db803 100644 --- a/src/data/ws-area_registry.ts +++ b/src/data/ws-area_registry.ts @@ -1,12 +1,17 @@ import { Connection, createCollection } from "home-assistant-js-websocket"; import { Store } from "home-assistant-js-websocket/dist/store"; +import { stringCompare } from "../common/string/compare"; import { debounce } from "../common/util/debounce"; import { AreaRegistryEntry } from "./area_registry"; const fetchAreaRegistry = (conn: Connection) => - conn.sendMessagePromise({ - type: "config/area_registry/list", - }); + conn + .sendMessagePromise({ + type: "config/area_registry/list", + }) + .then((areas) => + areas.sort((ent1, ent2) => stringCompare(ent1.name, ent2.name)) + ); const subscribeAreaRegistryUpdates = ( conn: Connection,