Take lang into account when sorting groups (#20355)

* Take lang into account when sorting groups

* make sure empty values are at the bottom
This commit is contained in:
Bram Kragten 2024-04-03 10:12:25 +02:00 committed by GitHub
parent bb20ab8c2c
commit 6c1f328d71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -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;