Skip to content

[Repo Assist] feat: add TaskSeq.rev, sort, sortDescending, sortBy/Async, sortByDescending/Async, sortWith (101 tests)#309

Closed
github-actions[bot] wants to merge 3 commits intomainfrom
repo-assist/feat-sort-rev-2026-03-a98697970c3e043d
Closed

[Repo Assist] feat: add TaskSeq.rev, sort, sortDescending, sortBy/Async, sortByDescending/Async, sortWith (101 tests)#309
github-actions[bot] wants to merge 3 commits intomainfrom
repo-assist/feat-sort-rev-2026-03-a98697970c3e043d

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 8, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Implements the sort/rev family of functions that were previously marked ❓ in the README with note #1 (requiring pre-materialisation before streaming).

Function Description
TaskSeq.rev Reverses the sequence (materialise, reverse, stream back)
TaskSeq.sort Ascending natural-comparison sort
TaskSeq.sortDescending Descending natural-comparison sort
TaskSeq.sortBy Ascending sort by synchronous projection
TaskSeq.sortByAsync Ascending sort by asynchronous projection
TaskSeq.sortByDescending Descending sort by synchronous projection
TaskSeq.sortByDescendingAsync Descending sort by asynchronous projection
TaskSeq.sortWith Sort using a custom comparison function

Design

All functions follow the same pattern:

  1. Materialise the full source sequence into a ResizeArray via the existing toResizeArrayAsync helper
  2. Apply the corresponding Array.* sort primitive (returns a new sorted array — non-mutating)
  3. Yield elements back as a TaskSeq

The async projection variants (sortByAsync/sortByDescendingAsync) additionally await each key computation sequentially before sorting.

Memory note: All these functions hold the entire sequence in memory. This is consistent with how Seq.sort, Seq.rev, etc. work in FSharp.Core — and is explicitly documented in XML doc comments and the README.

Test Status

All tests pass — 3,897 tests pass (2 skipped as usual), including 101 new sort/rev tests.

New tests cover:

  • Null argument guard (each function)
  • Empty sequence variants (each function)
  • Single-element sequences
  • Multi-element sequences with integers, strings, tuples
  • Async key projection variants using Task.FromResult
  • Invariants: rev ∘ rev = id, sortByDescending = rev ∘ sortBy, sync/async parity
  • Custom comparers in sortWith

Build and formatting (Fantomas) both pass.

Changes

  • TaskSeqInternal.fs — implementations of all 8 functions
  • TaskSeq.fs — static member wrappers
  • TaskSeq.fsi — XML-doc'd signatures with correct type constraints
  • TaskSeq.Sort.Tests.fs — 101 new tests (new file)
  • FSharp.Control.TaskSeq.Test.fsproj — adds Sort test file
  • README.md — marks sort/rev as ✅ implemented
  • release-notes.txt — adds entry under v0.5.0

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@ec7d342403c9912c87320110f8822a8fbb817a0c

…ending/Async, sortWith (101 tests)

Implements the remaining sort/rev family of functions that were previously
marked as '?' in the README (requiring pre-materialisation before streaming).

New functions:
- TaskSeq.rev                   — reverses by materialising into array first
- TaskSeq.sort                  — ascending natural comparison sort
- TaskSeq.sortDescending        — descending natural comparison sort
- TaskSeq.sortBy                — ascending sort by projection (sync)
- TaskSeq.sortByAsync           — ascending sort by projection (async)
- TaskSeq.sortByDescending      — descending sort by projection (sync)
- TaskSeq.sortByDescendingAsync — descending sort by projection (async)
- TaskSeq.sortWith              — sort using custom comparison function

All functions materialise the full input sequence, apply the corresponding
Array sort primitive, then stream elements back as a TaskSeq.

Includes 101 tests. README and release-notes updated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 8, 2026 01:14
@dsyme
Copy link
Contributor

dsyme commented Mar 8, 2026

Let's not do these, they aren't very useful

@dsyme dsyme closed this Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants