From 6c1f328d71befe30bc59363184ec4fe1d69a48a7 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 3 Apr 2024 10:12:25 +0200 Subject: [PATCH] Take lang into account when sorting groups (#20355) * Take lang into account when sorting groups * make sure empty values are at the bottom --- src/components/data-table/ha-data-table.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/data-table/ha-data-table.ts b/src/components/data-table/ha-data-table.ts index e0f7c8894e..2c95735e82 100644 --- a/src/components/data-table/ha-data-table.ts +++ b/src/components/data-table/ha-data-table.ts @@ -33,6 +33,7 @@ import "../ha-svg-icon"; import "../search-input"; import { filterData, sortData } from "./sort-filter"; import { groupBy } from "../../common/util/group-by"; +import { stringCompare } from "../../common/string/compare"; declare global { // for fire event @@ -529,7 +530,13 @@ export class HaDataTable extends LitElement { const sorted: { [key: string]: DataTableRowData[]; } = Object.keys(grouped) - .sort() + .sort((a, b) => + stringCompare( + ["", "-", "—"].includes(a) ? "zzz" : a, + ["", "-", "—"].includes(b) ? "zzz" : b, + this.hass.locale.language + ) + ) .reduce((obj, key) => { obj[key] = grouped[key]; return obj;