[Repo Assist] Add AsyncSeq.sortByAsync and sortByDescendingAsync#285
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
[Repo Assist] Add AsyncSeq.sortByAsync and sortByDescendingAsync#285github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
Adds two new async sorting functions that mirror the existing 'Async' variants pattern of minByAsync, maxByAsync, and countByAsync: - sortByAsync: sorts by an async key projection, returning Async<array<'T>> - sortByDescendingAsync: same but in descending order Both functions compute each key exactly once per element, then sort. 5 new tests added; all 326 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds two new async sort functions that fill a small gap in the
AsyncSeqAPI and are consistent with the existing*Asyncpattern established byminByAsync,maxByAsync,countByAsync, andsumByAsync.sortByAsyncAsync(array<'T)>minByAsync/maxByAsyncsortByDescendingAsyncsortByDescendingsync twinMotivation
AsyncSeqalready hassortBy(sync projection) andsortByDescending. The common*Asynctwins for projection-based operations (minByAsync,maxByAsync,countByAsync,sumByAsync) are all present.sortByAsync/sortByDescendingAsyncwere the only obvious gap.Use case example: ordering query results by an async-computed property (e.g. a cached value fetched from a remote store):
Implementation
Both functions use
mapAsyncto pair each element with its projection key (computing the key exactly once), thentoArrayAsyncto materialise, then a standardArray.sort*call:Changes
src/FSharp.Control.AsyncSeq/AsyncSeq.fs— 2 new function implementationssrc/FSharp.Control.AsyncSeq/AsyncSeq.fsi— 2 new public signatures with XML-doctests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs— 5 new testsRELEASE_NOTES.md— 4.10.1 entryNew Tests
sortByAsync sorts ascending by async projectionsortByAsync returns empty array for empty sequencesortByAsync computes projection exactly once per elementsortByDescendingAsync sorts descending by async projectionsortByDescendingAsync returns empty array for empty sequenceTest Status
✅ Build succeeded (0 errors, pre-existing warnings only — NU1605, FS9999 for
groupByAsync).✅ All 326 tests pass — 5 new, 321 pre-existing.