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

Method sortBy

external/.scrollLibs.js:17532–17549  ·  view source on GitHub ↗
(nameOrNames)

Source from the content-addressed store, hash-verified

17530 return this
17531 }
17532 sortBy(nameOrNames) {
17533 const names = nameOrNames instanceof Array ? nameOrNames : [nameOrNames]
17534 const length = names.length
17535 this.sort((particleA, particleB) => {
17536 if (!particleB.length && !particleA.length) return 0
17537 else if (!particleA.length) return -1
17538 else if (!particleB.length) return 1
17539 for (let index = 0; index < length; index++) {
17540 const cue = names[index]
17541 const av = particleA.get(cue)
17542 const bv = particleB.get(cue)
17543 if (av > bv) return 1
17544 else if (av < bv) return -1
17545 }
17546 return 0
17547 })
17548 return this
17549 }
17550 selectParticle() {
17551 this._selected = true
17552 }

Callers

nothing calls this directly

Calls 2

sortMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected