ng2-table
ng2-table copied to clipboard
Sorting for columns of type strings is case sensitive
Is it possible to have the sorting on columns of type string not to consider the case?
You can change this by modifying the sort function in your code. The easiest way is to add toLowerCase() on the comparisons in the sample code:
// simple sorting
return data.sort((previous:any, current:any) => {
if (previous[columnName].toLowerCase() > current[columnName].toLowerCase()) {
return sort === 'desc' ? -1 : 1;
} else if (previous[columnName].toLowerCase() < current[columnName].toLowerCase()) {
return sort === 'asc' ? -1 : 1;
}