MCPcopy Create free account
hub / github.com/breck7/scroll / _fnSortDisplay

Function _fnSortDisplay

external/.datatables.js:5218–5242  ·  view source on GitHub ↗

* Sort the display array to match the master's order * @param {*} settings

(settings, display)

Source from the content-addressed store, hash-verified

5216 * @param {*} settings
5217 */
5218 function _fnSortDisplay(settings, display) {
5219 if (display.length < 2) {
5220 return
5221 }
5222
5223 var master = settings.aiDisplayMaster
5224 var masterMap = {}
5225 var map = {}
5226 var i
5227
5228 // Rather than needing an `indexOf` on master array, we can create a map
5229 for (i = 0; i < master.length; i++) {
5230 masterMap[master[i]] = i
5231 }
5232
5233 // And then cache what would be the indexOf fom the display
5234 for (i = 0; i < display.length; i++) {
5235 map[display[i]] = masterMap[display[i]]
5236 }
5237
5238 display.sort(function (a, b) {
5239 // Short version of this function is simply `master.indexOf(a) - master.indexOf(b);`
5240 return map[a] - map[b]
5241 })
5242 }
5243
5244 function _fnSortResolve(settings, nestedSort, sort) {
5245 var push = function (a) {

Callers 2

_fnSortAttachListenerFunction · 0.85
__row_selectorFunction · 0.85

Calls 1

sortMethod · 0.80

Tested by

no test coverage detected