Commit d433cf8c d433cf8ca19443b3cc0da33afd9ba73721f72603 by Nicolas Perriault

fixed sorting issue in googlematch sample

1 parent 324be9d1
...@@ -39,7 +39,7 @@ casper.each terms, (self, term) -> ...@@ -39,7 +39,7 @@ casper.each terms, (self, term) ->
39 self.echo "#{term}: #{score}" 39 self.echo "#{term}: #{score}"
40 40
41 casper.run -> 41 casper.run ->
42 scores.sort -> (a, b) -> b.score > a.score 42 scores.sort -> (a, b) -> b.score - a.score;
43 winner = scores[0] 43 winner = scores[0]
44 @echo "Winner is #{winner.term} with #{winner.score} results" 44 @echo "Winner is #{winner.term} with #{winner.score} results"
45 @exit() 45 @exit()
......
...@@ -47,7 +47,7 @@ casper.each(terms, function(self, term, i) { ...@@ -47,7 +47,7 @@ casper.each(terms, function(self, term, i) {
47 47
48 casper.run(function(self) { 48 casper.run(function(self) {
49 scores.sort(function(a, b) { 49 scores.sort(function(a, b) {
50 return b.score > a.score; 50 return b.score - a.score;
51 }); 51 });
52 var winner = scores[0]; 52 var winner = scores[0];
53 self.echo('winner is "' + winner.term + '" with ' + winner.score + ' results'); 53 self.echo('winner is "' + winner.term + '" with ' + winner.score + ' results');
......