Skip to content

Commit bd4a7d6

Browse files
authored
Merge pull request scala/scala#10122 from lbhuang2015/2.13.x
fix Median-of-three pivot selection in quickSort method
2 parents 4f12421 + a08034c commit bd4a7d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/src/scala/util/Sorting.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ object Sorting {
6666
else
6767
if (ord.compare(a(i0), a(iK)) < 0) i0
6868
else
69-
if (ord.compare(a(iN - 1), a(iK)) <= 0) iN - 1
70-
else iK
69+
if (ord.compare(a(iN - 1), a(iK)) <= 0) iK
70+
else iN - 1
7171
val pivot = a(pL)
7272
// pL is the start of the pivot block; move it into the middle if needed
7373
if (pL != iK) { a(pL) = a(iK); a(iK) = pivot; pL = iK }

0 commit comments

Comments
 (0)