'use strict';

module.exports = (columns, column, done) => {
    // reset old classes
    columns.forEach(function (col) {
        col.headerClass = col.headerClass.replace('sort-asc', '');
        col.headerClass = col.headerClass.replace('sort-desc', '');
    });

    column.sort = column.sort === 'asc' ? 'desc' : 'asc';

    // push sorting hint
    column.headerClass += ' sort-' + column.sort;

    done({
        sortingColumn: column,
        columns: columns
    });
};

// sorter === lodash sortByOrder
// https://lodash.com/docs#sortByOrder
module.exports.sort = (data, column, sorter) => {
    if (!column) {
        return data;
    }

    return sorter(data, [column.property], [column.sort]);
};

@@ -8,16 +8,50 @@
 rict';%0A%0A
+import %7BisString%7D from 'lodash';%0A%0A
 module.e
@@ -685,44 +685,181 @@
     
-r
+l
 et
-urn
  sort
-er(data, %5Bcolumn.property
+Fn = function (row) %7B%0A        let value = row%5Bcolumn.property%5D;%0A        return isString(value) ? value.toLowerCase() : value;%0A    %7D;%0A%0A    return sorter(data, %5BsortFn
 %5D, %5B
@@ -871,13 +871,12 @@
 n.sort%5D);%0A%7D;
-%0A

case-insensitive sort