Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pretty bad sortby bug

  • Loading branch information...
commit c0aab91833d0dfeeaaaf7cc03b407c6fb32c018d 1 parent a98f76a
@sconover authored
Showing with 2 additions and 1 deletion.
  1. +1 −1  lib/collection_functions.js
  2. +1 −0  spec/collection/sort_by_spec.js
View
2  lib/collection_functions.js
@@ -182,7 +182,7 @@ CollectionFunctions = (function(){
array.sort(function(a,b){
var aValue = evaluator(a),
bValue = evaluator(b)
- return a==b ? 0 : (a<b ? 1 : -1)
+ return aValue==bValue ? 0 : (aValue>bValue ? 1 : -1)
})
var sortedCollection = map(array, function(item){return item}, features.newCollection, features.append)
return sortedCollection
View
1  spec/collection/sort_by_spec.js
@@ -6,6 +6,7 @@ describe("sort by", function() {
it("sorts the collection by the value returned out of the callback", function(){
expect(fArr.sortBy([5,6,7,8], function(item){return -1 * item})).toEqual([8,7,6,5])
+ expect(fArr.sortBy([5,7,8,6], function(item){return item})).toEqual([5,6,7,8])
expect(fArr.sortBy([], function(item){return -1 * item})).toEqual([])
})
Please sign in to comment.
Something went wrong with that request. Please try again.