fixed sorting issue in googlematch sample
Showing
2 changed files
with
2 additions
and
2 deletions
... | @@ -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'); | ... | ... |
-
Please register or sign in to post a comment