Skip to content
Snippets Groups Projects
Commit ef8fdb82 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

NG_UI : vocabulary form - natural and case-insensitive sorting of terms...

NG_UI : vocabulary form - natural and case-insensitive sorting of terms (properly sorts alphanumerical values, e.g. 'A2' will be before 'a10')
parent e419f58c
No related branches found
No related tags found
No related merge requests found
...@@ -338,13 +338,17 @@ export default class GridController { ...@@ -338,13 +338,17 @@ export default class GridController {
_sort(rows, columns, sort, sortDirection) { _sort(rows, columns, sort, sortDirection) {
if (sort) { if (sort) {
let column = _.find(columns, ['field', sort]) const column = _.find(columns, ['field', sort])
if (column) { if (column) {
const collator = new Intl.Collator(undefined, {
numeric: true,
sensitivity: 'base'
})
return rows.sort((t1, t2) => { return rows.sort((t1, t2) => {
let sign = sortDirection === 'asc' ? 1 : -1 let sign = sortDirection === 'asc' ? 1 : -1
let v1 = this._getValue(t1, column.field) let v1 = this._getValue(t1, column.field)
let v2 = this._getValue(t2, column.field) let v2 = this._getValue(t2, column.field)
return sign * v1.localeCompare(v2) return sign * collator.compare(v1, v2)
}) })
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment