Run Kwker in your browser. Pick an example or write your own, then press Run. Your code gets the library as kwk and prints with print(...).
kwk can do herekwk.sort(a, {descending, nansFirst}) | Sorts a typed array in place and returns it. |
kwk.argsort(a, opts) | The positions that would sort a (a Uint32Array). Stable: equal keys keep their order. |
kwk.topK(a, k, opts) | The k smallest (or largest, with descending) keys and their positions. |
kwk.select(a, k, opts) | Moves the value a full sort would put at index k to a[k]. Values before it are smaller or equal, values after it larger or equal; neither side is sorted. |
kwk.partialSort(a, k, opts) | Sorts just the first k positions. |
kwk.sortStrings(list, collation) | Sorts strings: "bytes", "caseless", "natural" or "natural_caseless". |
kwk.argsortStrings(list, collation) | The positions that would sort the strings. |
kwk.isa(), kwk.version() | The engine in use and the library version. |
Typed arrays: Int8Array through Float64Array, BigInt64Array and BigUint64Array. Floats sort with -0 before +0 and NaN last.
The playground runs Kwker compiled to WebAssembly (SIMD128 lanes and the portable engine). The native libraries for Python, Rust, C and the other languages run the AVX-512, AVX2, NEON or SVE engines on your CPU, and they are much faster. Their results are the same.