(values, ...F)
| 541 | } |
| 542 | |
| 543 | function 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 | |
| 566 | function compareDefined(compare = ascending$3) { |
| 567 | if (compare === ascending$3) return ascendingDefined; |
no test coverage detected