# antsort

> `Another sort` - sort elements by level, before and afte.

Latest version **1.1.2** (published 2015-12-20) · ISC license · 0 weekly downloads

## Install

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

## 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.1.2 |
| Published | 2015-12-20 |
| First published | 2015-12-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | bencode@163.com |
| Maintainers | bencode |

## Links

- npm: https://www.npmjs.com/package/antsort
- Repository: https://github.com/bencode/antsort
- Homepage: https://github.com/bencode/antsort#readme
- Issues: https://github.com/bencode/antsort/issues
- npm.io page: https://npm.io/package/antsort

## Recent versions

- 1.1.2 (latest) — 2015-12-20
- 1.1.1 — 2015-12-04
- 1.1.0 — 2015-12-02
- 1.0.1 — 2015-12-02
- 1.0.0 — 2015-12-02

## README

# antsort


[![Build Status](https://travis-ci.org/bencode/antsort.svg?branch=master)](https://travis-ci.org/bencode/antsort)
[![Coverage Status](https://coveralls.io/repos/bencode/antsort/badge.svg?branch=master&service=github)](https://coveralls.io/github/bencode/antsort?branch=master)


`Another sort` - sort elements by level, before and afte.


### antsort(list)


```js
var sort = require('antsort');

var list = [
  {
    name: 'a',
    level: 3
  },

  {
    name: 'b',
    level: 4
  },

  {
    name: 'c',
    before: 'b'
  },

  {
    name: 'd',
    level: 3
  },

  {
    name: 'e',
    after: 'a'
  }
];


var sorted = sort(list);

sorted.map(item => item.name)
    .should.be.eql(['a', 'e', 'd', 'c', 'b']);
```


### antsort(list, { defaultLevel: ... })


```js
var list = [
  {
    name: 'a',
    level: 1
  },

  {
    name: 'b'  // will be last
  },

  {
    name: 'c',
    level: 1
  }
];

sort(list).map(item => item.name)
    .should.be.eql(['a', 'c', 'b']);

sort(list, { defaultLevel: 0 }).map(item => item.name)
    .should.be.eql(['b', 'a', 'c']);

```

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