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

Function sort

external/.d3.js:543–564  ·  view source on GitHub ↗
(values, ...F)

Source from the content-addressed store, hash-verified

541}
542
543function sort(values, ...F) {
544 if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
545 values = Array.from(values);
546 let [f] = F;
547 if ((f && f.length !== 2) || F.length > 1) {
548 const index = Uint32Array.from(values, (d, i) => i);
549 if (F.length > 1) {
550 F = F.map(f => values.map(f));
551 index.sort((i, j) => {
552 for (const f of F) {
553 const c = ascendingDefined(f[i], f[j]);
554 if (c) return c;
555 }
556 });
557 } else {
558 f = values.map(f);
559 index.sort((i, j) => ascendingDefined(f[i], f[j]));
560 }
561 return permute(values, index);
562 }
563 return values.sort(compareDefined(f));
564}
565
566function compareDefined(compare = ascending$3) {
567 if (compare === ascending$3) return ascendingDefined;

Callers 2

groupSortFunction · 0.85
pieFunction · 0.85

Calls 6

ascendingDefinedFunction · 0.85
permuteFunction · 0.85
compareDefinedFunction · 0.85
mapMethod · 0.80
sortMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected