@@ -3456,6 +3456,47 @@ let ``AsyncSeq.sortWith returns empty array for empty sequence`` () =
34563456 let result = AsyncSeq.sortWith compare AsyncSeq.empty< int>
34573457 Assert.AreEqual([||], result)
34583458
3459+ // ===== sortAsync / sortByAsync / sortDescendingAsync / sortByDescendingAsync / sortWithAsync =====
3460+
3461+ [<Test>]
3462+ let ``AsyncSeq.sortAsync sorts in ascending order`` () =
3463+ let result = AsyncSeq.ofSeq [ 3 ; 1 ; 4 ; 1 ; 5 ; 9 ] |> AsyncSeq.sortAsync |> Async.RunSynchronously
3464+ Assert.AreEqual([| 1 ; 1 ; 3 ; 4 ; 5 ; 9 |], result)
3465+
3466+ [<Test>]
3467+ let ``AsyncSeq.sortAsync returns empty array for empty sequence`` () =
3468+ let result = AsyncSeq.empty< int> |> AsyncSeq.sortAsync |> Async.RunSynchronously
3469+ Assert.AreEqual([||], result)
3470+
3471+ [<Test>]
3472+ let ``AsyncSeq.sortByAsync sorts by projected key`` () =
3473+ let result =
3474+ AsyncSeq.ofSeq [ " banana" ; " apple" ; " cherry" ]
3475+ |> AsyncSeq.sortByAsync ( fun s -> s.Length)
3476+ |> Async.RunSynchronously
3477+ Assert.AreEqual([| " apple" ; " banana" ; " cherry" |], result)
3478+
3479+ [<Test>]
3480+ let ``AsyncSeq.sortDescendingAsync sorts in descending order`` () =
3481+ let result = AsyncSeq.ofSeq [ 3 ; 1 ; 4 ; 1 ; 5 ] |> AsyncSeq.sortDescendingAsync |> Async.RunSynchronously
3482+ Assert.AreEqual([| 5 ; 4 ; 3 ; 1 ; 1 |], result)
3483+
3484+ [<Test>]
3485+ let ``AsyncSeq.sortByDescendingAsync sorts by projected key descending`` () =
3486+ let result =
3487+ AsyncSeq.ofSeq [ " apple" ; " banana" ; " fig" ]
3488+ |> AsyncSeq.sortByDescendingAsync ( fun s -> s.Length)
3489+ |> Async.RunSynchronously
3490+ Assert.AreEqual([| " banana" ; " apple" ; " fig" |], result)
3491+
3492+ [<Test>]
3493+ let ``AsyncSeq.sortWithAsync sorts using custom comparer`` () =
3494+ let result =
3495+ AsyncSeq.ofSeq [ 3 ; 1 ; 4 ; 1 ; 5 ]
3496+ |> AsyncSeq.sortWithAsync ( fun a b -> compare b a)
3497+ |> Async.RunSynchronously
3498+ Assert.AreEqual([| 5 ; 4 ; 3 ; 1 ; 1 |], result)
3499+
34593500// ── AsyncSeq.mapFold ──────────────────────────────────────────────────────────
34603501
34613502[<Test>]
0 commit comments