Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sortBy function improve #1247

Closed
wants to merge 1 commit into from
Closed

sortBy function improve #1247

wants to merge 1 commit into from

Conversation

sjpsega
Copy link
Contributor

@sjpsega sjpsega commented Aug 7, 2013

I use underscore in Adobe PhotoShop js writing;It's js environment is special,it's Array sort function is special,It may happen left and right is equal.

@braddunbar
Copy link
Collaborator

Hi @sjpsega! I could be wrong, but I don't think left and right can ever be === since they are created in the _.map above and will most certainly be different objects.

@sjpsega
Copy link
Contributor Author

sjpsega commented Aug 8, 2013

@braddunbar InDesign(Adobe PhotoShop is) is special.I run my example in chrome、firefox and IE6 is corrent,but in Adobe PhotoShop is incorrect.

@jdalton

[1,2].sort(function(a,b) { alert([a, b]); return 1; });
// -> alerts 2, 1
// -> alerts 1, 1 <-- issue

your example is proof in InDesign may happen left and right be equal.
but your second example is to sample.

My example is:

var testArr = [{num:991},{num:212},{num:11},{num:16},{num:74},{num:0},{num:1515}];
var result = _.sortBy(testArr,function(obj) { 
                                    return obj.num;
                                    });
//in chrome:     [{"num":0},{"num":11},{"num":16},{"num":74},{"num":212},{"num":991},{"num":1515}] (correct)
//in InDesign:   [{"num":0},{"num":212},{"num":11},{"num":16},{"num":74},{"num":991},{"num":1515}] (incorrect)

@braddunbar
Copy link
Collaborator

Fixed by #1253.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants