https://github.com/ragingwind/semver-sort
Sort array of semver string even which is exist in a strings.
https://github.com/ragingwind/semver-sort
Last synced: 9 months ago
JSON representation
Sort array of semver string even which is exist in a strings.
- Host: GitHub
- URL: https://github.com/ragingwind/semver-sort
- Owner: ragingwind
- License: mit
- Created: 2015-09-19T00:14:37.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-12-15T10:34:59.000Z (over 4 years ago)
- Last Synced: 2025-09-15T06:21:52.896Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 21
- Watchers: 1
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# semver-sort [](https://travis-ci.org/ragingwind/semver-sort)
> Sort array of semver string even which is exist in a strings.
## Install
```
$ npm install --save semver-sort
```
## Usage
```js
var version = [
'v0.0.2',
'v0.1.1',
'2.0.1',
'1.2.2',
'1.1.1',
'v0.0.9'
];
var semverSort = require('semver-sort');
semverSort.asc(version);
//=> [ 'v0.0.2', 'v0.0.9', 'v0.1.1', '1.1.1', '1.2.2', '2.0.1' ]
semverSort.desc(version);
//=> [ '2.0.1', '1.2.2', '1.1.1', 'v0.1.1', 'v0.0.9', 'v0.0.2' ]
var tags = [
{ref: 'refs/tags/v1.0.2'},
{ref: 'refs/tags/v0.1.1'},
{ref: 'refs/tags/v0.1.0'},
{ref: 'refs/tags/v1.1.0'},
{ref: 'refs/tags/v1.0.3'},
{ref: 'refs/tags/v1.0.1'},
{ref: 'refs/tags/v1.0.0'}
];
semverSort.asc(tags.map(function (tag) {
return tag.ref;
}));
//=> [ 'refs/tags/v0.1.0', 'refs/tags/v0.1.1', 'refs/tags/v1.0.0', 'refs/tags/v1.0.1', 'refs/tags/v1.0.2', 'refs/tags/v1.0.3', 'refs/tags/v1.1.0' ]
```
## License
MIT © [Jimmy Moon](http://ragingwind.me)