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

feat(orderBy): Stable sort the input array #12408

Closed
wants to merge 1 commit into from

Conversation

lgalfaso
Copy link
Contributor

Stable sort the input array

@lgalfaso
Copy link
Contributor Author

This indirectly fixes #12405

@lgalfaso lgalfaso changed the title feat(orderBy): Stable sort the input feat(orderBy): Stable sort the input array Jul 22, 2015
@Narretz Narretz added this to the 1.4.5 milestone Aug 3, 2015
@Narretz
Copy link
Contributor

Narretz commented Aug 3, 2015

Does this have a performance implications?

@lgalfaso
Copy link
Contributor Author

lgalfaso commented Aug 4, 2015

Does this have a performance implications?

This only adds a natural comparator with the original element position, so
this adds some cycles but much smaller than even one $parse evaluation

@@ -183,6 +183,7 @@ function orderByFilter($parse) {
if (sortPredicate.length === 0) { sortPredicate = ['+']; }

var predicates = processPredicates(sortPredicate, reverseOrder);
predicates.push({ get: function() { return {}; }, descending: reverseOrder ? -1 : 1});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave a comment explaining this, it won't be very nice to have to look up this issue in the blame for this function to figure out what this means once it stops being clear, otherwise this looks maybe a bit brittle

Just a quick header comment with an overview explaining how the predicate works, imho

@caitp
Copy link
Contributor

caitp commented Aug 4, 2015

This only adds a natural comparator with the original element position, so
this adds some cycles but much smaller than even one $parse evaluation

It might still be a good idea to look at the impact this has on the bigtable benchmarks, and put some numbers in the commit message and issue --- so that there's a bit more confidence there. Can we do that?

@lgalfaso
Copy link
Contributor Author

lgalfaso commented Aug 6, 2015

Run order_by benchpress several times with and without the patch

With the patch
mean: 152.74ms ± 22%
(stddev 33.61)

Without the patch
mean: 156.36ms ± 32%
(stddev 53.76)

This PR does not make the code any faster (as the numbers look like they claim), but do show that the variations between runs is much bigger than whatever performance penalty this patch adds

@Narretz
Copy link
Contributor

Narretz commented Aug 8, 2015

Can you add to the commit message that it fixes #12405? Otherwise LGTM

Stable sort the input array

Fixes angular#12405
@lgalfaso lgalfaso closed this in ed3a33a Aug 8, 2015
ggershoni pushed a commit to ggershoni/angular.js that referenced this pull request Sep 29, 2015
Stable sort the input array

Closes angular#12408
Fixes angular#12405
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants