[Pkg-javascript-commits] [node-async] 409/480: added readme example to show inversion of sort order

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit ea884124781c12c27a360309a1a9aa89b42beaa8
Author: zaphod1984 <zaphod84 at gmx.de>
Date:   Thu Feb 16 21:03:02 2012 +0100

    added readme example to show inversion of sort order
---
 README.md | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

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" />

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list