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

Method sortByColumns

external/.scrollLibs.js:17426–17444  ·  view source on GitHub ↗
(indexOrIndices)

Source from the content-addressed store, hash-verified

17424 }
17425 // todo: remove?
17426 sortByColumns(indexOrIndices) {
17427 const indices = indexOrIndices instanceof Array ? indexOrIndices : [indexOrIndices]
17428 const length = indices.length
17429 this.sort((particleA, particleB) => {
17430 const atomsA = particleA.atoms
17431 const atomsB = particleB.atoms
17432 for (let index = 0; index < length; index++) {
17433 const col = indices[index]
17434 const av = atomsA[col]
17435 const bv = atomsB[col]
17436 if (av === undefined) return -1
17437 if (bv === undefined) return 1
17438 if (av > bv) return 1
17439 else if (av < bv) return -1
17440 }
17441 return 0
17442 })
17443 return this
17444 }
17445 getAtomsAsSet() {
17446 return new Set(this.getAtomsFrom(1))
17447 }

Callers

nothing calls this directly

Calls 1

sortMethod · 0.95

Tested by

no test coverage detected