@@ -212,7 +212,7 @@ function orderByFilter($parse) {
212
212
} ;
213
213
214
214
function processPredicates ( sortPredicate , reverseOrder ) {
215
- var reverseOrder = reverseOrder ? - 1 : 1 ;
215
+ reverseOrder = reverseOrder ? - 1 : 1 ;
216
216
return sortPredicate . map ( function ( predicate ) {
217
217
var descending = 1 , get = identity ;
218
218
@@ -246,33 +246,27 @@ function orderByFilter($parse) {
246
246
}
247
247
}
248
248
249
- function objectToString ( value ) {
249
+ function objectValue ( value , index ) {
250
250
if ( typeof value . valueOf === 'function' ) {
251
251
value = value . valueOf ( ) ;
252
252
if ( isPrimitive ( value ) ) return value ;
253
253
}
254
- if ( typeof value . toString === 'function' ) {
254
+ if ( hasCustomToString ( value ) ) {
255
255
value = value . toString ( ) ;
256
256
if ( isPrimitive ( value ) ) return value ;
257
257
}
258
- return '' ;
258
+ return index ;
259
259
}
260
260
261
261
function getPredicateValue ( value , index ) {
262
262
var type = typeof value ;
263
263
if ( value === null ) {
264
- type = 'null' ;
264
+ type = 'string' ;
265
+ value = 'null' ;
265
266
} else if ( type === 'string' ) {
266
267
value = value . toLowerCase ( ) ;
267
268
} else if ( type === 'object' ) {
268
- value = objectToString ( value ) ;
269
-
270
- // If the object is a POJO then it doesn't really have a well defined ordering
271
- // To allow us to reverse the order of these objects, we artificially use its current
272
- // index in the collection as its value
273
- if ( value === '[object Object]' ) {
274
- value = index ;
275
- }
269
+ value = objectValue ( value , index ) ;
276
270
}
277
271
return { value : value , type : type } ;
278
272
}
0 commit comments