angular-filter icon indicating copy to clipboard operation
angular-filter copied to clipboard

GroupBy + OrderBy doesn't order by dates in Chrome

Open apuchkov opened this issue 10 years ago • 9 comments

Here's JS Bin of GroupBy + OrderBy http://jsbin.com/qewono/1/edit

A few observations:

  • It only doesn't work in Chrome. In IE records ordered correctly
  • It only breaks when there are many records. If you try to remove first dozen of records it orders correctly
  • plain Angular's OrderBy filter works well on the same array http://jsbin.com/beciva/3/edit

apuchkov avatar Feb 20 '15 22:02 apuchkov

@apuchkov , you should do it this way: jsbin thx

a8m avatar Feb 21 '15 09:02 a8m

Thanks a lot!

apuchkov avatar Feb 21 '15 16:02 apuchkov

Cheers :beers: @apuchkov

a8m avatar Feb 21 '15 16:02 a8m

In my previous jsbin I didn't actually used dates, but strings formatted like dates.

If I put real dates, then ordering breaks http://jsbin.com/qayili/1/edit

apuchkov avatar Feb 23 '15 13:02 apuchkov

@apuchkov I'm not sure if it's a bug.. I'll look deeply later.. for now, here's a quick fix for that: jsbin.

a8m avatar Feb 23 '15 14:02 a8m

Cool, also for some reason Date formatting doesn't work for $key:

<h2>{{ rate.$key | date:'yyyy-MM-dd' }}</h2>

apuchkov avatar Feb 23 '15 14:02 apuchkov

so, change the cast function to:

$scope.cast = function(arr) {
  return arr.$key = new Date(arr.$key);
}

a8m avatar Feb 23 '15 14:02 a8m

What if you want to groupBy a different variable then you want to orderBy?

dangnelson avatar Jul 29 '15 20:07 dangnelson

I am having the same issue too. The GroupBy order shows correctly in Firefox but in Chrome it is showing in descending order.

Mr-Anonymous avatar Nov 13 '15 14:11 Mr-Anonymous