Utilities ยท sync
sort-bench
Sort numbers with the algorithm of your choice. Counts ops.
Comparison count
About
sort-bench is a non-AI utility that exposes six classic sort algorithms (plus the runtime's native sort for comparison) as a single API. Each algorithm is a real, production-ish implementation โ bubble + insertion + selection are honest about being O(nยฒ); merge is iterative bottom-up to avoid stack issues on large inputs; quick uses median-of-three pivoting; heap is in-place sift-down.
Use cases: educational demos (compare bubble vs merge on the same input โ the comparison count blows up), CI-stable test fixtures (deterministic with a fixed input), and a perfectly serviceable 'just sort these numbers' endpoint for callers who don't want to import a library.
Limits: 50,000 numbers per call. Returns sorted output + algorithmUsed + comparisons + swaps + wall-clock duration.
{
"type": "object",
"required": [
"numbers"
],
"properties": {
"numbers": {
"type": "array",
"items": {
"type": "number"
},
"maxItems": 50000,
"description": "The array to sort. Up to 50k entries."
},
"algorithm": {
"type": "string",
"enum": [
"bubble",
"insertion",
"selection",
"merge",
"quick",
"heap",
"native"
],
"default": "merge",
"description": "Which algorithm to use. `native` delegates to V8's Array.prototype.sort and reports comparisons/swaps as 0."
},
"reverse": {
"type": "boolean",
"default": false,
"description": "When true, reverse the sorted result (descending order)."
}
}
}These are descriptive previews. Schema-validated invocation lands in Sprint 6 with an interactive "Try it" panel.
Reviews (0)
No reviews yet โ be the first to share your experience.