diff --git a/packages/react-bootstrap-table2/src/store/sort.js b/packages/react-bootstrap-table2/src/store/sort.js index 1f349ac5c..0ca63e72a 100644 --- a/packages/react-bootstrap-table2/src/store/sort.js +++ b/packages/react-bootstrap-table2/src/store/sort.js @@ -4,14 +4,13 @@ import _ from '../utils'; import Const from '../const'; +const collator = new Intl.Collator(); function comparator(a, b) { - let result; if (typeof b === 'string') { - result = b.localeCompare(a); + return collator.compare(a, b); } else { - result = a > b ? -1 : ((a < b) ? 1 : 0); + return a > b ? -1 : ((a < b) ? 1 : 0); } - return result; } export const sort = (data, sortOrder, { dataField, sortFunc, sortValue }) => { diff --git a/packages/react-bootstrap-table2/src/utils.js b/packages/react-bootstrap-table2/src/utils.js index 23d3cc21a..fc8369f7d 100644 --- a/packages/react-bootstrap-table2/src/utils.js +++ b/packages/react-bootstrap-table2/src/utils.js @@ -4,11 +4,9 @@ import _ from 'underscore'; function splitNested(str) { - return [str] - .join('.') - .replace(/\[/g, '.') - .replace(/\]/g, '') - .split('.'); + return str + .replace(']', '') + .split(/\[\./); } function contains(list, value) { @@ -58,8 +56,8 @@ function isEmptyObject(obj) { const hasOwnProperty = Object.prototype.hasOwnProperty; const keys = Object.keys(obj); - for (let i = 0; i < keys.length; i += 1) { - if (hasOwnProperty.call(obj, keys[i])) return false; + for (let key of keys) { + if (hasOwnProperty.call(obj, key)) return false; } return true;