# qqsort

> fast, non-blocking quicksort

Latest version **1.0.9** (published 2019-01-17) · Apache-2.0 license · 0 weekly downloads

## Install

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

## 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 | 1.0.9 |
| Published | 2019-01-17 |
| First published | 2015-10-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | git://github.com/andrasq/ |
| Maintainers | andrasq |
| Keywords | Andras, nonblocking, quicksort, qsort, yielding, non-blocking, quick, sort |

## Links

- npm: https://www.npmjs.com/package/qqsort
- Repository: https://github.com/andrasq/node-qqsort
- Homepage: https://github.com/andrasq/node-qqsort#readme
- Issues: https://github.com/andrasq/node-qqsort/issues
- npm.io page: https://npm.io/package/qqsort

## Recent versions

- 1.0.9 (latest) — 2019-01-17
- 1.0.8 — 2017-10-24
- 1.0.7 — 2016-03-11
- 1.0.5 — 2015-11-12
- 1.0.4 — 2015-11-06
- 1.0.2 — 2015-10-19
- 1.0.0 — 2015-10-18

## README

qqsort
======
[![Build Status](https://travis-ci.org/andrasq/node-qqsort.svg?branch=master)](https://travis-ci.org/andrasq/node-qqsort?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/andrasq/node-qqsort/badge.svg?branch=master)](https://coveralls.io/github/andrasq/node-qqsort?branch=master)

quick, non-blocking quicksort

Traditional in-place quicksort, but yields to the event loop both while
partitioning the array and between passes.  Pivot picked at random.

I needed a sort function for real-world, large dataset use.  It had to be
non-blocking to support very large arrays and/or complex comparator functions,
and had to allow for fatal errors in the comparator if the data was not
sortable.

`qqsort` does not block the event loop, allows duplicate values, and catches
errors thrown by the comparator.

        var qqsort = require('qqsort')

        var data = [2,3,1,4]
        qqsort(data, function(err) {
            // data => [1,2,3,4]
        })

        var data = [{a:2}, {a:3}, {a:1}, {a:4}]
        qqsort(data, function(a,b) { return a.a - b.a }, function(err) {
            // data => [{a:1}, {a:2}, {a:3}, {a:4}]
        })


API
---

### qqsort( array, [comparator(e1, e2),] callback(err [,array]) )

Reorder the elements of the array in-place as established by the comparator
function.

The comparator, if provided, will be passed array elements e1 and e2, and should
return -1 if e1 is to precede e2, 1 if e1 is to follow e2, and 0 if they are the
same.  The default comparator is `function(e1, e2) { return (e1 < e2) ? -1 : (e1 > e2) ? 1 : 0 }`

The callback will be called with any error thrown by the comparator function
and, for convenience, the modified input data array.


Changelog
---------

- 1.0.9 - 35% faster and less blocking
- 1.0.5 - fail gracefully if not passed an array
- 1.0.4 - also support node v0.8
- 1.0.2 - yield more often
- 1.0.0 - initial version

Related Work
------------

Searching for `sort`, `qsort`, `quicksort`, `shellsort` turns up lots of
packages, but all seem to be pedagogic or experimental.  The one I saw that took
a callback still sorted synchronously internally, and used the callback only for
call linkage.

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