Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

orderBy doesn't reverse order if no predicate specified. #11866

Closed
wawyed opened this issue May 13, 2015 · 3 comments · Fixed by #12072
Closed

orderBy doesn't reverse order if no predicate specified. #11866

wawyed opened this issue May 13, 2015 · 3 comments · Fixed by #12072

Comments

@wawyed
Copy link

wawyed commented May 13, 2015

According to the documentation: https://docs.angularjs.org/api/ng/filter/orderBy.

If no property is provided, (e.g. '+') then the array element itself is used to compare where sorting.

This seems to be working fine in 1.3.5 but it seems to have been broken in 1.3.6+.

Probably caused by: 8bfeddb

Plnkr with the issue: http://plnkr.co/edit/vaOJzuDdkJUookDVSuDK?p=preview

@wawyed wawyed changed the title orderBy doesn't reverse order if no predicament specified. orderBy doesn't reverse order if no predicate specified. May 13, 2015
@Narretz Narretz added this to the 1.4.0-rc.3 milestone May 18, 2015
@petebacondarwin petebacondarwin modified the milestones: 1.4.x - jaracimrman-existence, 1.4.0-rc.3 May 18, 2015
@hena-3
Copy link

hena-3 commented May 20, 2015

I also checked this issue -
In 1.4 -

  1. If no property given then its giving in same order (ascending of array elements) (correct according to doc)
  2. if '-'is given even then its giving in same order(ascending of array elements) (Bug)

In 1.3 -

  1. If no property given then its giving in reverse order (descending of array elements) (Bug)
  2. if '+'is given even then its giving in reverse order(descending of array elements) (Bug)

@hena-3
Copy link

hena-3 commented May 21, 2015

In this issue -
Its working fine when using simple array element(string array or number array), but does not work with array of objects .
For array of objects we can JSON.stringify the object and then compare, as .toString() will not work for objects.
I have checked its working with JSON.stringify.
Please let me know if this approach is ok, I will send the pull request.

@Narretz Narretz modified the milestones: 1.4.1, 1.4.x Jun 5, 2015
@Narretz
Copy link
Contributor

Narretz commented Jun 5, 2015

Hi @hena-3 feel free to submit a PR, we'll review it. Though JSON.stringify sounds a bit unperformant, but we'll see.

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 10, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 10, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 10, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 10, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 10, 2015
@petebacondarwin petebacondarwin modified the milestones: 1.4.1, 1.4.2 Jun 16, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 16, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 16, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 16, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 16, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 16, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 16, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 16, 2015
…redicate

By refactoring to use a Schwartzian transform, we can ensure that objects
with no custom `toString` or `toValue` methods are just ordered using
their position in the original collection.

Closes angular#11866
Closes angular#11312
Closes angular#4282
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 17, 2015
…redicate

By refactoring to use a Schwartzian transform, we can ensure that objects
with no custom `toString` or `toValue` methods are just ordered using
their position in the original collection.

Closes angular#11866
Closes angular#11312
Closes angular#4282
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 18, 2015
…redicate

By refactoring to use a Schwartzian transform, we can ensure that objects
with no custom `toString` or `toValue` methods are just ordered using
their position in the original collection.

Closes angular#11866
Closes angular#11312
Closes angular#4282
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 18, 2015
…redicate

By refactoring to use a Schwartzian transform, we can ensure that objects
with no custom `toString` or `toValue` methods are just ordered using
their position in the original collection.

Closes angular#11866
Closes angular#11312
Closes angular#4282
petebacondarwin added a commit that referenced this issue Jun 18, 2015
…redicate

By refactoring to use a Schwartzian transform, we can ensure that objects
with no custom `toString` or `toValue` methods are just ordered using
their position in the original collection.

Closes #11866
Closes #11312
Closes #4282
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
…redicate

By refactoring to use a Schwartzian transform, we can ensure that objects
with no custom `toString` or `toValue` methods are just ordered using
their position in the original collection.

Closes angular#11866
Closes angular#11312
Closes angular#4282
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants