Skip to content
This repository was archived by the owner on Jan 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions build/reactable.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ window.ReactDOM["default"] = window.ReactDOM;
sort: true,
sortBy: true,
sortableColumns: true,
defaultSortFunction: true,
onSort: true,
defaultSort: true,
defaultSortDescending: true,
Expand Down Expand Up @@ -1337,32 +1338,29 @@ window.ReactDOM["default"] = window.ReactDOM;
}

this.data.sort((function (a, b) {
var keyA = (0, _libExtract_data_from.extractDataFrom)(a, currentSort.column);
var keyA = (0, _libExtract_data_from.extractDataFrom)(currentSort.direction === 1 ? a : b, currentSort.column);
keyA = (0, _unsafe.isUnsafe)(keyA) ? keyA.toString() : keyA || '';
var keyB = (0, _libExtract_data_from.extractDataFrom)(b, currentSort.column);
var keyB = (0, _libExtract_data_from.extractDataFrom)(currentSort.direction === 1 ? b : a, currentSort.column);
keyB = (0, _unsafe.isUnsafe)(keyB) ? keyB.toString() : keyB || '';

// Default sort
if (typeof this._sortable[currentSort.column] === 'undefined' || this._sortable[currentSort.column] === 'default') {
if (typeof this.props.defaultSortFunction !== 'undefined') {
return this.props.defaultSortFunction(keyA, keyB);
}

// Reverse direction if we're doing a reverse sort
// Default sort
if (keyA < keyB) {
return -1 * currentSort.direction;
return -1;
}

if (keyA > keyB) {
return 1 * currentSort.direction;
return 1;
}

return 0;
} else {
// Reverse columns if we're doing a reverse sort
if (currentSort.direction === 1) {
return this._sortable[currentSort.column](keyA, keyB);
} else {
return this._sortable[currentSort.column](keyB, keyA);
}
}

return this._sortable[currentSort.column](keyA, keyB);
}).bind(this));
}
}, {
Expand Down
1 change: 1 addition & 0 deletions lib/reactable/lib/filter_props_from.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var internalProps = {
sort: true,
sortBy: true,
sortableColumns: true,
defaultSortFunction: true,
onSort: true,
defaultSort: true,
defaultSortDescending: true,
Expand Down
23 changes: 10 additions & 13 deletions lib/reactable/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,32 +344,29 @@ var Table = (function (_React$Component) {
}

this.data.sort((function (a, b) {
var keyA = (0, _libExtract_data_from.extractDataFrom)(a, currentSort.column);
var keyA = (0, _libExtract_data_from.extractDataFrom)(currentSort.direction === 1 ? a : b, currentSort.column);
keyA = (0, _unsafe.isUnsafe)(keyA) ? keyA.toString() : keyA || '';
var keyB = (0, _libExtract_data_from.extractDataFrom)(b, currentSort.column);
var keyB = (0, _libExtract_data_from.extractDataFrom)(currentSort.direction === 1 ? b : a, currentSort.column);
keyB = (0, _unsafe.isUnsafe)(keyB) ? keyB.toString() : keyB || '';

// Default sort
if (typeof this._sortable[currentSort.column] === 'undefined' || this._sortable[currentSort.column] === 'default') {
if (typeof this.props.defaultSortFunction !== 'undefined') {
return this.props.defaultSortFunction(keyA, keyB);
}

// Reverse direction if we're doing a reverse sort
// Default sort
if (keyA < keyB) {
return -1 * currentSort.direction;
return -1;
}

if (keyA > keyB) {
return 1 * currentSort.direction;
return 1;
}

return 0;
} else {
// Reverse columns if we're doing a reverse sort
if (currentSort.direction === 1) {
return this._sortable[currentSort.column](keyA, keyB);
} else {
return this._sortable[currentSort.column](keyB, keyA);
}
}

return this._sortable[currentSort.column](keyA, keyB);
}).bind(this));
}
}, {
Expand Down
1 change: 1 addition & 0 deletions src/reactable/lib/filter_props_from.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const internalProps = {
sort: true,
sortBy: true,
sortableColumns: true,
defaultSortFunction: true,
onSort: true,
defaultSort: true,
defaultSortDescending: true,
Expand Down
23 changes: 10 additions & 13 deletions src/reactable/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,35 +299,32 @@ export class Table extends React.Component {
}

this.data.sort(function(a, b){
let keyA = extractDataFrom(a, currentSort.column);
let keyA = extractDataFrom(currentSort.direction === 1 ? a : b, currentSort.column);
keyA = isUnsafe(keyA) ? keyA.toString() : keyA || '';
let keyB = extractDataFrom(b, currentSort.column);
let keyB = extractDataFrom(currentSort.direction === 1 ? b : a, currentSort.column);
keyB = isUnsafe(keyB) ? keyB.toString() : keyB || '';

// Default sort
if (
typeof(this._sortable[currentSort.column]) === 'undefined' ||
this._sortable[currentSort.column] === 'default'
) {
if (typeof this.props.defaultSortFunction !== 'undefined') {
return this.props.defaultSortFunction(keyA, keyB);
}

// Reverse direction if we're doing a reverse sort
// Default sort
if (keyA < keyB) {
return -1 * currentSort.direction;
return -1;
}

if (keyA > keyB) {
return 1 * currentSort.direction;
return 1;
}

return 0;
} else {
// Reverse columns if we're doing a reverse sort
if (currentSort.direction === 1) {
return this._sortable[currentSort.column](keyA, keyB);
} else {
return this._sortable[currentSort.column](keyB, keyA);
}
}

return this._sortable[currentSort.column](keyA, keyB);
}.bind(this));
}

Expand Down