diff --git a/docs/columns.md b/docs/columns.md index 330b7ad..d472e67 100644 --- a/docs/columns.md +++ b/docs/columns.md @@ -121,15 +121,15 @@ It's only used for [`column.formatter`](#formatter), you can define any value fo Enable the column sort via a `true` value given. ## column.sortFunc - [Function] -`column.sortFunc` only work when `column.sort` is enable. `sortFunc` allow you to define your sorting algorithm. This callback function accept four arguments: +`column.sortFunc` only work when `column.sort` is enable. `sortFunc` allow you to define your sorting algorithm. This callback function accept six arguments: ```js { // omit... sort: true, - sortFunc: (a, b, order, dataField) => { - if (order === 'asc') return a - b; - else return b - a; + sortFunc: (valueA, valueB, order, dataField, rowA, rowB) => { + if (order === 'asc') return valueA - valueB; + else return valueB - valueA; } } ``` diff --git a/packages/react-bootstrap-table2/src/store/sort.js b/packages/react-bootstrap-table2/src/store/sort.js index ecbfbd7..dd2fd21 100644 --- a/packages/react-bootstrap-table2/src/store/sort.js +++ b/packages/react-bootstrap-table2/src/store/sort.js @@ -24,7 +24,7 @@ export const sort = (data, sortOrder, { dataField, sortFunc }) => { valueB = _.isDefined(valueB) ? valueB : ''; if (sortFunc) { - result = sortFunc(valueA, valueB, sortOrder, dataField); + result = sortFunc(valueA, valueB, sortOrder, dataField, a, b); } else { if (sortOrder === Const.SORT_DESC) { result = comparator(valueA, valueB);