diff --git a/src/ng/filter/orderBy.js b/src/ng/filter/orderBy.js index f18c96b1768c..58b4c4bcd3e9 100644 --- a/src/ng/filter/orderBy.js +++ b/src/ng/filter/orderBy.js @@ -172,14 +172,14 @@ function orderByFilter($parse) { function objectToString(value) { if (value === null) return 'null'; - if (typeof value.toString === 'function') { - value = value.toString(); - if (isPrimitive(value)) return value; - } if (typeof value.valueOf === 'function') { value = value.valueOf(); if (isPrimitive(value)) return value; } + if (typeof value.toString === 'function') { + value = value.toString(); + if (isPrimitive(value)) return value; + } return ''; } diff --git a/test/ng/filter/orderBySpec.js b/test/ng/filter/orderBySpec.js index 120425ba78ea..17cd6b47dbb4 100644 --- a/test/ng/filter/orderBySpec.js +++ b/test/ng/filter/orderBySpec.js @@ -79,6 +79,16 @@ describe('Filter: orderBy', function() { { a:new Date('01/01/2014'), b:3 }]); }); + it('should compare timestamps when sorting dates', function() { + expect(orderBy([ + new Date('01/01/2015'), + new Date('01/01/2014') + ])).toEqualData([ + new Date('01/01/2014'), + new Date('01/01/2015') + ]); + }); + it('should use function', function() { expect(