{"library":"quickselect","title":"Quickselect","description":"quickselect is a highly optimized, tiny JavaScript library implementing the Floyd-Rivest selection algorithm. It efficiently partially sorts an array in-place, ensuring that elements up to a specified index `k` are the smallest in the given range. The current stable version is 3.0.0, which was a significant update dropping CommonJS and UMD builds, making it exclusively ESM and requiring modern ES syntax. Releases appear to be infrequent, driven by significant architectural changes or feature additions. Its primary differentiator is its minimal footprint and speed for selection tasks compared to full sorting algorithms, making it ideal for scenarios where only a subset of sorted elements is needed.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install quickselect"],"cli":null},"imports":["import quickselect from 'quickselect';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import quickselect from 'quickselect';\n\nconst arr = [65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39];\n\n// Rearrange the array such that elements up to index 8 are the smallest.\n// The 8th element (0-indexed) will be the (8 - 0 + 1)th smallest value in the original array.\nquickselect(arr, 8);\n\nconsole.log(arr);\n// Expected output similar to: [39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95]\n// Note: The order of elements *before* k is not guaranteed, only that they are smaller than or equal to arr[k].\n","lang":"typescript","description":"This example demonstrates how to use `quickselect` to partially sort an array in-place, ensuring that elements up to a specific index `k` are the smallest in the given range.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}