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:
parent
bb20ab8c2c
commit
6c1f328d71
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue