Skip to content

sortBy function improve#1247

Closed
sjpsega wants to merge 1 commit intojashkenas:masterfrom
sjpsega:master
Closed

sortBy function improve#1247
sjpsega wants to merge 1 commit intojashkenas:masterfrom
sjpsega:master

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.

This was referenced Mar 1, 2026
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.

3 participants