Skip to content

Commit 9a165f1

Browse files
committed
Fix wrong order of compare function for minBy|maxBy and variants
1 parent c0c5e80 commit 9a165f1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/FSharp.Control.TaskSeq/TaskSeqInternal.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ module internal TaskSeqInternal =
195195
return acc
196196
}
197197

198+
// 'compare' is either `<` or `>` (i.e, less-than, greater-than resp.)
198199
let inline maxMinBy ([<InlineIfLambda>] compare) ([<InlineIfLambda>] projection) (source: TaskSeq<_>) =
199200
checkNonNull (nameof source) source
200201

@@ -213,14 +214,14 @@ module internal TaskSeqInternal =
213214
let value = e.Current
214215
let currentProjection = projection value
215216

216-
if compare currentProjection accProjection then
217+
if compare accProjection currentProjection then
217218
accProjection <- currentProjection
218219
accValue <- value
219220

220221
return accValue
221222
}
222223

223-
224+
// 'compare' is either `<` or `>` (i.e, less-than, greater-than resp.)
224225
let inline maxMinByAsync ([<InlineIfLambda>] compare) ([<InlineIfLambda>] projectionAsync) (source: TaskSeq<_>) =
225226
checkNonNull (nameof source) source
226227

@@ -240,7 +241,7 @@ module internal TaskSeqInternal =
240241
let value = e.Current
241242
let! currentProjection = projectionAsync value
242243

243-
if compare currentProjection accProjection then
244+
if compare accProjection currentProjection then
244245
accProjection <- currentProjection
245246
accValue <- value
246247

0 commit comments

Comments
 (0)