1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-23 13:52:26 +08:00

feat: add Sorted for stream

This commit is contained in:
dudaodong
2023-02-08 15:07:09 +08:00
parent 6bba44dc50
commit 5075774000
2 changed files with 23 additions and 1 deletions

View File

@@ -303,3 +303,14 @@ func TestStream_Concat(t *testing.T) {
assert.Equal([]int{1, 2, 3, 4, 5, 6}, s.ToSlice())
}
func TestStream_Sorted(t *testing.T) {
assert := internal.NewAssert(t, "TestStream_Sorted")
s := FromSlice([]int{4, 2, 1, 3})
s1 := s.Sorted(func(a, b int) bool { return a < b })
assert.Equal([]int{4, 2, 1, 3}, s.ToSlice())
assert.Equal([]int{1, 2, 3, 4}, s1.ToSlice())
}