Skip to content

Commit 5e369b5

Browse files
actions-userCopilot
authored andcommitted
feat: add TaskSeq.rev, sort, sortDescending, sortBy/Async, sortByDescending/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>
1 parent 43eff83 commit 5e369b5

File tree

8 files changed

+577
-7
lines changed

8 files changed

+577
-7
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,19 @@ This is what has been implemented so far, is planned or skipped:
341341
| &#x2705; [#236][]| `removeAt` | `removeAt` | | |
342342
| &#x2705; [#236][]| `removeManyAt` | `removeManyAt` | | |
343343
| | `replicate` | `replicate` | | |
344-
| &#x2753; | `rev` | | | [note #1](#note1 "These functions require a form of pre-materializing through 'TaskSeq.cache', similar to the approach taken in the corresponding 'Seq' functions. It doesn't make much sense to have a cached async sequence. However, 'AsyncSeq' does implement these, so we'll probably do so eventually as well.") |
344+
| &#x2705; | `rev` | `rev` | | materializes sequence before yielding |
345345
| | `scan` | `scan` | `scanAsync` | |
346346
| &#x1f6ab; | `scanBack` | | | [note #2](#note2 "Because of the async nature of TaskSeq sequences, iterating from the back would be bad practice. Instead, materialize the sequence to a list or array and then apply the 'Back' iterators.") |
347347
| &#x2705; [#90][] | `singleton` | `singleton` | | |
348348
| &#x2705; [#209][]| `skip` | `skip` | | |
349349
| &#x2705; [#219][]| `skipWhile` | `skipWhile` | `skipWhileAsync` | |
350350
| &#x2705; [#219][]| | `skipWhileInclusive` | `skipWhileInclusiveAsync` | |
351-
| &#x2753; | `sort` | | | [note #1](#note1 "These functions require a form of pre-materializing through 'TaskSeq.cache', similar to the approach taken in the corresponding 'Seq' functions. It doesn't make much sense to have a cached async sequence. However, 'AsyncSeq' does implement these, so we'll probably do so eventually as well.") |
352-
| &#x2753; | `sortBy` | | | [note #1](#note1 "These functions require a form of pre-materializing through 'TaskSeq.cache', similar to the approach taken in the corresponding 'Seq' functions. It doesn't make much sense to have a cached async sequence. However, 'AsyncSeq' does implement these, so we'll probably do so eventually as well.") |
353-
| &#x2753; | `sortByAscending` | | | [note #1](#note1 "These functions require a form of pre-materializing through 'TaskSeq.cache', similar to the approach taken in the corresponding 'Seq' functions. It doesn't make much sense to have a cached async sequence. However, 'AsyncSeq' does implement these, so we'll probably do so eventually as well.") |
354-
| &#x2753; | `sortByDescending` | | | [note #1](#note1 "These functions require a form of pre-materializing through 'TaskSeq.cache', similar to the approach taken in the corresponding 'Seq' functions. It doesn't make much sense to have a cached async sequence. However, 'AsyncSeq' does implement these, so we'll probably do so eventually as well.") |
355-
| &#x2753; | `sortWith` | | | [note #1](#note1 "These functions require a form of pre-materializing through 'TaskSeq.cache', similar to the approach taken in the corresponding 'Seq' functions. It doesn't make much sense to have a cached async sequence. However, 'AsyncSeq' does implement these, so we'll probably do so eventually as well.") |
351+
| &#x2705; | `sort` | `sort` | | materializes sequence before yielding |
352+
| | | `sortDescending` | | materializes sequence before yielding |
353+
| &#x2705; | `sortBy` | `sortBy` | `sortByAsync` | materializes sequence before yielding |
354+
| &#x2705; | `sortByAscending` | `sortBy` | `sortByAsync` | same as `sortBy`; materializes sequence before yielding |
355+
| &#x2705; | `sortByDescending` | `sortByDescending` | `sortByDescendingAsync` | materializes sequence before yielding |
356+
| &#x2705; | `sortWith` | `sortWith` | | materializes sequence before yielding |
356357
| | `splitInto` | `splitInto` | | |
357358
| | `sum` | `sum` | | |
358359
| | `sumBy` | `sumBy` | `sumByAsync` | |

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "10.0.103",
3+
"version": "10.0.102",
44
"rollForward": "minor"
55
}
66
}

release-notes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Release notes:
55
- update engineering to .NET 9/10
66
- adds TaskSeq.scan and TaskSeq.scanAsync, #289
77
- adds TaskSeq.pairwise, #289
8+
- adds TaskSeq.rev, sort, sortDescending, sortBy, sortByAsync,
9+
sortByDescending, sortByDescendingAsync, sortWith
810

911
0.4.0
1012
- overhaul all doc comments, add exceptions, improve IDE quick-info experience, #136, #220, #234

src/FSharp.Control.TaskSeq.Test/FSharp.Control.TaskSeq.Test.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<Compile Include="TaskSeq.Except.Tests.fs" />
2222
<Compile Include="TaskSeq.DistinctUntilChanged.Tests.fs" />
2323
<Compile Include="TaskSeq.Pairwise.Tests.fs" />
24+
<Compile Include="TaskSeq.Sort.Tests.fs" />
2425
<Compile Include="TaskSeq.Exists.Tests.fs" />
2526
<Compile Include="TaskSeq.Filter.Tests.fs" />
2627
<Compile Include="TaskSeq.FindIndex.Tests.fs" />

0 commit comments

Comments
 (0)