# asorted

> Fast and efficient sorted arrays in JavaScript

Latest version **0.0.3** (published 2014-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install asorted
pnpm add asorted
yarn add asorted
bun add asorted
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2014-11-14 |
| First published | 2014-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Daniel Norman |
| Maintainers | 2color |
| Keywords | JavaScript, js, array, binary, serach, objects, json, reactjs, fluxjs |

## Links

- npm: https://www.npmjs.com/package/asorted
- Repository: https://github.com/2color/asorted
- Issues: https://github.com/2color/asorted/issues
- npm.io page: https://npm.io/package/asorted

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.3 (latest) — 2014-11-14
- 0.0.2 — 2014-11-14
- 0.0.1 — 2014-11-14

## README

# Asorted
Fast sorted array in Javascript. Uses binary search for addition and deletion.

## Installation

**node.js** `npm install asorted`

## Examples

```javascript
var Asorted = require("asorted");
var sorted = new Asorted(4, 42, 8, 16, 15, 23);
console.log(sorted.array);                      // [ 4, 8, 15, 16, 23, 42 ]
sorted.search(16);                              // 3
sorted.search(3);                               // -1
sorted.remove(16);                              // [ 4, 8, 15, 23, 42 ]
sorted.insert(16);                              // [ 4, 8, 15, 16, 23, 42 ]
sorted.insert(50000);                           // [ 4, 8, 15, 16, 23, 42, 50000 ]

var sorted2 = new Asorted({ sortBy: 'size'}, { name: 'Danny', size: 10 }, { name: 'Linux', size: 9 } );
//[ { name: 'Linus', size: 9 }, { name: 'Danny', size: 10 } ]
sorted2.insert({ name: 'Jeremey', size: 20 });
//[ { name: 'Linux', size: 9 },
//  { name: 'Danny', size: 10 },
//  { name: 'Jeremey', size: 20 } ]


```

## Geeky stuff
Since binary search is used for adding and deleting, these operations should be in O(log n).
This however is just for finding the appropriate index. The splice operation is dependent on the browsers implementation.
Modern browsers heavily optimize these operations but the since this uses a dynamic array the worst case could be O(n).

## Roadmap
- ~~Implemenet sorted arrays of objects. When working with flux.js stores, I normally
use native arrays for lists. Coming from backbone.js which has collections which are
basically fancy arrays I need a replacement which can keep an array of objects
sorted based on a given key. So that's the plan. Pull requests are welcome.~~
- Get this on bower, npm and whatever-package-manger-is-now-cool

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