electricessence / TypeScript.NET

A JavaScript-Friendly .NET Based TypeScript Library (Moved)
https://github.com/electricessence/TypeScript.NET-Core
Other
251 stars 36 forks source link

orderBy is not working #12

Closed DJHightower closed 9 years ago

DJHightower commented 9 years ago

Sample code for reproduction:

                var sorted = Linq.Enumerable.fromArray<ICustomer>(customers)
                    .orderBy(c => c.Name)
                    .toArray();

Let ICustomer be some Interface with a Name-property. Then look at "sorted"'s values. Most of them are "undefined" :-(

electricessence commented 9 years ago

Investigating now.

electricessence commented 9 years ago

Whoops... Wrong button. DIdn't want to close.

electricessence commented 9 years ago

Added unit tests for order by and they failed immediately. Fixing.

electricessence commented 9 years ago

806a484c52070b60df51914badf52c45be501dfd This was an interesting bug because it wouldn't show itself 100% in Firefox but would do so in IE because IE apparently has a different array.sort algorithm and does things in reverse? With the results going forward (a>b) was enough to correctly sort. But with array.sort in reverse (a>b) wouldn't trigger and would then fall through to (b<a) which is simply the above written backwards. It was supposed to be (b>a). This was a really important find because System.compare is a core method that was causing ordering madness. The fix for undefined was in the previous commit.