ng2-table icon indicating copy to clipboard operation
ng2-table copied to clipboard

Sorting for columns of type strings is case sensitive

Open munawwars opened this issue 10 years ago • 1 comments

Is it possible to have the sorting on columns of type string not to consider the case?

munawwars avatar May 19 '16 04:05 munawwars

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

ph1ll avatar May 23 '16 14:05 ph1ll