summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzaphod1984 <zaphod84@gmx.de>2012-02-16 21:03:02 +0100
committerCaolan McMahon <caolan@caolanmcmahon.com>2014-03-28 16:45:03 +0000
commitea884124781c12c27a360309a1a9aa89b42beaa8 (patch)
tree9d9dcc96f3852c200fd521cb5fab6cff7165b335
parentfb8a0ed14fedd36e3e2e47b4f950cd5259f02f81 (diff)
downloadasync-ea884124781c12c27a360309a1a9aa89b42beaa8.tar.gz
added readme example to show inversion of sort order
-rw-r--r--README.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md
index f7d4f7a..a60ca4d 100644
--- a/README.md
+++ b/README.md
@@ -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" />