* Maps the given elements to their corresponding positions in a sorted array. * @protected * @param {array} elements Array of elements * @return {array} Array with the corresponding position for each element
(elements)
| 202 | * @return {array} Array with the corresponding position for each element |
| 203 | */ |
| 204 | mapElementsToSortedPosition (elements) { |
| 205 | const length = elements.length |
| 206 | const map = new Array(length) |
| 207 | const from = elements.slice() |
| 208 | const to = elements.slice().sort() |
| 209 | let index |
| 210 | |
| 211 | for (let k = 0; k < length; k++) { |
| 212 | index = from.indexOf(to[k]) |
| 213 | map[k] = index |
| 214 | // Flag the element as claimed, with that duplicate elements are mapped to |
| 215 | // different sorted positions |
| 216 | delete from[index] |
| 217 | } |
| 218 | |
| 219 | return map |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Triggered when a setting field has changed. |
no test coverage detected