diff options
author | zaphod1984 <zaphod84@gmx.de> | 2012-02-16 21:03:02 +0100 |
---|---|---|
committer | Caolan McMahon <caolan@caolanmcmahon.com> | 2014-03-28 16:45:03 +0000 |
commit | ea884124781c12c27a360309a1a9aa89b42beaa8 (patch) | |
tree | 9d9dcc96f3852c200fd521cb5fab6cff7165b335 | |
parent | fb8a0ed14fedd36e3e2e47b4f950cd5259f02f81 (diff) | |
download | async-ea884124781c12c27a360309a1a9aa89b42beaa8.tar.gz |
added readme example to show inversion of sort order
-rw-r--r-- | README.md | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -530,6 +530,25 @@ async.sortBy(['file1','file2','file3'], function(file, callback){ }); ``` +__Sort Order__ + +By modifying the callback parameter the sorting order can be influenced: + + //ascending order + async.sortBy([1,9,3,5], function(x, callback){ + callback(err, x); + }, function(err,result){ + //result callback + } ); + + //descending order + async.sortBy([1,9,3,5], function(x, callback){ + callback(err, x*-1); //<- x*-1 instead of x, turns the order around + }, function(err,result){ + //result callback + } ); + + --------------------------------------- <a name="some" /> |