https://github.com/public-transport/vbb-sort-lines
Sort VBB lines by their importance.
https://github.com/public-transport/vbb-sort-lines
fptf public-transportation transport
Last synced: over 1 year ago
JSON representation
Sort VBB lines by their importance.
- Host: GitHub
- URL: https://github.com/public-transport/vbb-sort-lines
- Owner: public-transport
- License: isc
- Created: 2017-04-05T21:19:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-03T15:58:14.000Z (about 6 years ago)
- Last Synced: 2025-04-12T23:25:59.629Z (over 1 year ago)
- Topics: fptf, public-transportation, transport
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# vbb-sort-lines
**Sort VBB lines by their importance.** Implements a heuristic to sort lines based on their mode of transport and name.
[](https://www.npmjs.com/package/vbb-sort-lines)
[](https://travis-ci.org/public-transport/vbb-sort-lines)

[](https://gitter.im/public-transport)
## Installing
```shell
npm install vbb-sort-lines
```
## Usage
`sortLines` compares two `line`s in [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format), so that it works with [Array.prototype.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).
```js
const sortLines = require('vbb-sort-lines')
console.log([
{type: 'line', id: '1', name: '11', mode: 'train'},
{type: 'line', id: '5', name: '300', mode: 'bus'},
{type: 'line', id: '2', name: '100', mode: 'train'},
{type: 'line', id: '4', name: 'M45', mode: 'bus'},
{type: 'line', id: '3', name: '10', mode: 'ferry'}
].sort(sortLines))
```
```js
[
{type: 'line', id: '1', name: '11', mode: 'train'},
{type: 'line', id: '2', name: '100', mode: 'train'},
{type: 'line', id: '3', name: '10', mode: 'ferry'},
{type: 'line', id: '4', name: 'M45', mode: 'bus'},
{type: 'line', id: '5', name: '300', mode: 'bus'}
]
```
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/public-transport/vbb-sort-lines/issues).