diff --git a/src/components/data-table/ha-data-table.ts b/src/components/data-table/ha-data-table.ts index a9d9bf3ea0..dad2d26efb 100644 --- a/src/components/data-table/ha-data-table.ts +++ b/src/components/data-table/ha-data-table.ts @@ -200,7 +200,6 @@ export class HaDataTable extends LitElement { Object.values(clonedColumns).forEach( (column: ClonedDataTableColumnData) => { delete column.title; - delete column.type; delete column.template; } ); diff --git a/src/components/data-table/sort_filter_worker.ts b/src/components/data-table/sort_filter_worker.ts index 286bae3014..36e756f91e 100644 --- a/src/components/data-table/sort_filter_worker.ts +++ b/src/components/data-table/sort_filter_worker.ts @@ -55,11 +55,16 @@ const sortData = ( ? b[column.valueColumn || sortColumn][column.filterKey] : b[column.valueColumn || sortColumn]; - if (typeof valA === "string") { - valA = valA.toUpperCase(); - } - if (typeof valB === "string") { - valB = valB.toUpperCase(); + if (column.type === "numeric") { + valA = isNaN(valA) ? undefined : Number(valA); + valB = isNaN(valB) ? undefined : Number(valB); + } else { + if (typeof valA === "string") { + valA = valA.toUpperCase(); + } + if (typeof valB === "string") { + valB = valB.toUpperCase(); + } } // Ensure "undefined" is always sorted to the bottom