diff --git a/components/lib/calendar/Calendar.vue b/components/lib/calendar/Calendar.vue index 5b2c2ab7e..51fe37747 100755 --- a/components/lib/calendar/Calendar.vue +++ b/components/lib/calendar/Calendar.vue @@ -2589,7 +2589,8 @@ export default { let innerHTML = ''; if (this.responsiveOptions) { - let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * new Intl.Collator(undefined, { numeric: true }).compare(o1.breakpoint, o2.breakpoint)); + const comparer = new Intl.Collator(undefined, { numeric: true }).compare; + let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * comparer(o1.breakpoint, o2.breakpoint)); for (let i = 0; i < responsiveOptions.length; i++) { let { breakpoint, numMonths } = responsiveOptions[i]; diff --git a/components/lib/carousel/Carousel.vue b/components/lib/carousel/Carousel.vue index 7393856cd..83ef0ef87 100755 --- a/components/lib/carousel/Carousel.vue +++ b/components/lib/carousel/Carousel.vue @@ -528,6 +528,7 @@ export default { if (this.responsiveOptions && !this.isUnstyled) { let _responsiveOptions = [...this.responsiveOptions]; + const comparer = new Intl.Collator(undefined, { numeric: true }).compare; _responsiveOptions.sort((data1, data2) => { const value1 = data1.breakpoint; @@ -537,7 +538,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return -1 * result; diff --git a/components/lib/datatable/DataTable.vue b/components/lib/datatable/DataTable.vue index df1b29e08..b02f9d4c5 100755 --- a/components/lib/datatable/DataTable.vue +++ b/components/lib/datatable/DataTable.vue @@ -523,6 +523,7 @@ export default { } data.sort((data1, data2) => { + const comparer = new Intl.Collator(undefined, { numeric: true }).compare; let value1 = resolvedFieldDatas.get(data1); let value2 = resolvedFieldDatas.get(data2); @@ -531,7 +532,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return this.d_sortOrder * result; @@ -567,7 +568,9 @@ export default { if (typeof value1 === 'string' || value1 instanceof String) { if (value1.localeCompare && value1 !== value2) { - return this.d_multiSortMeta[index].order * new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); + const comparer = new Intl.Collator(undefined, { numeric: true }).compare; + + return this.d_multiSortMeta[index].order * comparer(value1, value2); } } else { result = value1 < value2 ? -1 : 1; diff --git a/components/lib/dataview/DataView.vue b/components/lib/dataview/DataView.vue index b6988883b..4cc5d8854 100755 --- a/components/lib/dataview/DataView.vue +++ b/components/lib/dataview/DataView.vue @@ -110,6 +110,7 @@ export default { sort() { if (this.value) { const value = [...this.value]; + const comparer = new Intl.Collator(undefined, { numeric: true }).compare; value.sort((data1, data2) => { let value1 = ObjectUtils.resolveFieldData(data1, this.sortField); @@ -119,7 +120,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return this.sortOrder * result; diff --git a/components/lib/galleria/GalleriaThumbnails.vue b/components/lib/galleria/GalleriaThumbnails.vue index e58009501..acd89e8d0 100755 --- a/components/lib/galleria/GalleriaThumbnails.vue +++ b/components/lib/galleria/GalleriaThumbnails.vue @@ -438,6 +438,8 @@ export default { if (this.responsiveOptions && !this.isUnstyled) { this.sortedResponsiveOptions = [...this.responsiveOptions]; + const comparer = new Intl.Collator(undefined, { numeric: true }).compare; + this.sortedResponsiveOptions.sort((data1, data2) => { const value1 = data1.breakpoint; const value2 = data2.breakpoint; @@ -446,7 +448,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return -1 * result; diff --git a/components/lib/treetable/TreeTable.vue b/components/lib/treetable/TreeTable.vue index e6c79001c..53caa185f 100755 --- a/components/lib/treetable/TreeTable.vue +++ b/components/lib/treetable/TreeTable.vue @@ -417,6 +417,7 @@ export default { }, sortNodesSingle(nodes) { let _nodes = [...nodes]; + const comparer = new Intl.Collator(undefined, { numeric: true }).compare; _nodes.sort((node1, node2) => { const value1 = ObjectUtils.resolveFieldData(node1.data, this.d_sortField); @@ -426,7 +427,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return this.d_sortOrder * result;