-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90105ee
commit 214b5af
Showing
2 changed files
with
9 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/*! | ||
* sort-asc <https://github.com/helpers/sort-asc> | ||
* | ||
* Copyright (c) 2014 Jon Schlinkert, contributors. | ||
* Copyright (c) 2014-2015 Jon Schlinkert. | ||
* Licensed under the MIT License | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = function (a, b) { | ||
return b < a ? -1 : 1; | ||
return a === b ? 0 : a.localeCompare(b); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
/*! | ||
* sort-asc <https://github.com/jonschlinkert/sort-asc> | ||
* | ||
* Copyright (c) 2014 Jon Schlinkert, contributors. | ||
* Licensed under the MIT License | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var sortAsc = require('./'); | ||
|
||
describe('sort object', function () { | ||
it('should sort keys in ascending order.', function () { | ||
var actual = (['a', 'b', 'c', 'd']).sort(sortAsc); | ||
assert.deepEqual(actual, ['d', 'c', 'b', 'a']); | ||
describe('sort ascending', function () { | ||
it('should sort elements in ascending order.', function () { | ||
assert.deepEqual(['d', 'c', 'b', 'a'].sort(sortAsc), ['a', 'b', 'c', 'd']); | ||
assert.deepEqual(['g', 'z', 'a', 'x'].sort(sortAsc), ['a', 'g', 'x', 'z']); | ||
assert.deepEqual(['z', 'z', 'a', 'z'].sort(sortAsc), ['a', 'z', 'z', 'z']); | ||
assert.deepEqual(['zz', 'z', 'aa', 'a'].sort(sortAsc), ['a', 'aa', 'z', 'zz']); | ||
assert.deepEqual(['aba', 'aab', 'acc', 'abb', 'aabb'].sort(sortAsc), ['aab', 'aabb', 'aba', 'abb', 'acc']); | ||
}); | ||
}); |