
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
quickselect
Advanced tools
A tiny and fast selection algorithm in JavaScript (specifically, Floyd-Rivest selection).
quickselect(array, k[, left, right, compareFn]);
Rearranges items so that all items in the [left, k] are the smallest.
The k-th element will have the (k - left + 1)-th smallest value in [left, right].
array: the array to partially sort (in place)k: middle index for partial sorting (as defined above)left: left index of the range to sort (0 by default)right: right index (last index of the array by default)compareFn: compare functionExample:
const arr = [65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39];
quickselect(arr, 8);
// arr is [39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95]
// ^^ middle index
The 'heap' package provides a way to create min and max heaps in JavaScript. While not directly offering the same functionality as quickselect, heaps can be used to efficiently find the k-th smallest or largest element by inserting elements into the heap and then extracting the minimum or maximum k times. This approach is more suited for streaming data or when multiple order statistics need to be found over time.
The 'simple-statistics' package offers a wide range of statistical functions, including a method for finding the median. While it does not provide a direct implementation of the quickselect algorithm, it uses sorting and other techniques to calculate various statistics, which can be useful in data analysis scenarios where more than just order statistics are needed.
FAQs
A tiny and fast selection algorithm in JavaScript.
The npm package quickselect receives a total of 8,355,512 weekly downloads. As such, quickselect popularity was classified as popular.
We found that quickselect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.