mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-29 07:04:09 +08:00
* Fix Sandbox command transport and pinned native setup Build the Linux LLVM helper and runtime pack before running both test lanes, and align native cache contracts with the current target policy. Full managed Sandbox gate passed. * Replace quadratic array sorting with stable merge sort Cover sort snapshots, consistent-comparator results, stable ties, and comparator complexity with Node differential fixtures. Document differences from V8 TimSort.
17 lines
628 B
TypeScript
17 lines
628 B
TypeScript
const source = new Uint8Array(256);
|
|
for (let i = 0; i < source.length; i++) source[i] = 255 - i;
|
|
|
|
let comparisons = 0;
|
|
const sorted = source.toSorted((a, b) => {
|
|
comparisons++;
|
|
if (comparisons > 5000) throw new Error("Uint8Array sort exceeded comparison budget");
|
|
return a - b;
|
|
});
|
|
console.log(sorted[0], sorted[255], source[0], source[255]);
|
|
|
|
const descending = source.toSorted((a, b) => b - a);
|
|
console.log(descending[0], descending[255], source[0], source[255]);
|
|
|
|
const defaults = new Uint8Array([9, 1, 7, 1, 5, 2]).toSorted();
|
|
console.log(defaults[0], defaults[1], defaults[2], defaults[3], defaults[4], defaults[5]);
|