# kth-smallest

> Find kth smallest element in an array of numbers in amortized linear time

Latest version **2.2.7** (published 2016-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install kth-smallest
pnpm add kth-smallest
yarn add kth-smallest
bun add kth-smallest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.7 |
| Published | 2016-07-07 |
| First published | 2016-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Griffin Michl |
| Maintainers | griffinmichl |

## Links

- npm: https://www.npmjs.com/package/kth-smallest
- Repository: https://github.com/gm758/kth-smallest
- Homepage: https://github.com/gm758/kth-smallest#readme
- Issues: https://github.com/gm758/kth-smallest/issues
- npm.io page: https://npm.io/package/kth-smallest

## Dependencies (1)

- [is-number](https://npm.io/package/is-number.md) ^2.1.0

## Recent versions

- 2.2.7 (latest) — 2016-07-07
- 2.2.6 — 2016-05-25
- 2.2.5 — 2016-05-24
- 2.2.4 — 2016-05-24
- 2.2.3 — 2016-05-24
- 2.2.2 — 2016-05-24
- 2.2.1 — 2016-05-24
- 2.2.0 — 2016-05-24
- 2.1.0 — 2016-05-24
- 2.0.1 — 2016-05-24

## README

## kth-smallest
Find kth smallest element in an arary of numbers

Uses a randomized quickselect to achieve O(n) average case time complexity

[![Build Status](https://travis-ci.org/gm758/kth-smallest.svg?branch=master)](https://travis-ci.org/gm758/kth-smallest)

## Install
```bash
$ npm install kth-smallest
```

## Usage
```js
import kthSmallest from 'kth-smallest'

kthSmallest([10, 20, 30, 40], 0)
// 10

kthSmallest([10, 20, 30, 40], 2)
// 30

kthSmallest([10, 20, 30, 40], -1)
// 40

```

## API
```js
kthSmallest :: number a => [a] -> integer -> a

kthSmallest(numbers, k)
```

__Arguments__
* `numbers` - An array of numbers
* `k` - 0-indexed target (pass negative numbers for largest)

---
_Source: https://npm.io/package/kth-smallest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
