diff --git a/src/components/datatable/DataTable.js b/src/components/datatable/DataTable.js index c83d7ed5f1..1078acbd6b 100644 --- a/src/components/datatable/DataTable.js +++ b/src/components/datatable/DataTable.js @@ -1181,19 +1181,21 @@ export class DataTable extends Component { const value2 = ObjectUtils.resolveFieldData(data2, multiSortMeta[index].field); let result = null; - if (typeof value1 === 'string' || value1 instanceof String) { - if (value1.localeCompare && (value1 !== value2)) { - return (multiSortMeta[index].order * value1.localeCompare(value2, undefined, { numeric: true })); - } - } - else { - result = (value1 < value2) ? -1 : 1; - } - if (value1 === value2) { return (multiSortMeta.length - 1) > (index) ? (this.multisortField(data1, data2, multiSortMeta, index + 1)) : 0; } + if (value1 == null && value2 != null) + result = -1; + else if (value1 != null && value2 == null) + result = 1; + else if (value1 == null && value2 == null) + result = 0; + else if (typeof value1 === 'string' && typeof value2 === 'string') + result = value1.localeCompare(value2, undefined, { numeric: true }); + else + result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0; + return (multiSortMeta[index].order * result); }