MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / sortNodes

Method sortNodes

src/gridstack-engine.ts:451–454  ·  view source on GitHub ↗

* Sort the nodes array from first to last, or reverse. * This is called during collision/placement operations to enforce a specific order. * * @param dir sort direction: 1 for ascending (first to last), -1 for descending (last to first) * @returns the engine instance for chaining *

(dir: 1 | -1 = 1)

Source from the content-addressed store, hash-verified

449 * engine.sortNodes(-1); // Sort descending
450 */
451 public sortNodes(dir: 1 | -1 = 1): GridStackEngine {
452 this.nodes = Utils.sort(this.nodes, dir);
453 return this;
454 }
455
456 /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */
457 protected _packNodes(): GridStackEngine {

Callers 6

_fixCollisionsMethod · 0.95
compactMethod · 0.95
_packNodesMethod · 0.95
saveMethod · 0.95
columnChangedMethod · 0.95

Calls 1

sortMethod · 0.80

Tested by

no test coverage detected