-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ImmutableArray extension methods for ordering #10608
Add ImmutableArray extension methods for ordering #10608
Conversation
This change introduces four sets of extension methods with overloads: - OrderAsArray(...) - OrderDescendingAsArray(...) - OrderByAsArray(...) - OrderByDescendingAsArray(...) Each of these operates on an `ImmutableArray<T>` and returns an `ImmutableArray<T>`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than general YAGNI, I have nothing against this PR... but didn't I just see a comment on another PR that mentioned there was a Sort method on ImmutableArray already?
It's odd to me that these exist if there is a Sort method, and/or that these don't use that Sort method.
What am I missing?
The primary reason is that
|
src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs
Outdated
Show resolved
Hide resolved
1. Don't sort if the array has zero or 1 element. 2. Don't sort if the array or the keys are already ordered. 3. Avoid creating an `IComparer<T>` until its time to actually sort Add tests for Comparison<T> overloads
@davidwengier / @ryzngard / @333fred - Feel free to take another look. The implementation has changed pretty significantly. |
This change introduces four sets of extension methods with overloads:
Each of these operates on an
ImmutableArray<T>
and returns anImmutableArray<T>
.