Fix sorting of FloatArray and DoubleArray
Use compareTo method instead of comparison operators
This commit is contained in:
committed by
SvyatoslavScherbina
parent
d424a1f1ce
commit
dd3ce12e28
@@ -274,9 +274,9 @@ private fun partition(
|
|||||||
var j = right
|
var j = right
|
||||||
val pivot = array[(left + right) / 2]
|
val pivot = array[(left + right) / 2]
|
||||||
while (i <= j) {
|
while (i <= j) {
|
||||||
while (array[i] < pivot)
|
while (array[i].compareTo(pivot) < 0)
|
||||||
i++
|
i++
|
||||||
while (array[j] > pivot)
|
while (array[j].compareTo(pivot) > 0)
|
||||||
j--
|
j--
|
||||||
if (i <= j) {
|
if (i <= j) {
|
||||||
val tmp = array[i]
|
val tmp = array[i]
|
||||||
@@ -305,9 +305,9 @@ private fun partition(
|
|||||||
var j = right
|
var j = right
|
||||||
val pivot = array[(left + right) / 2]
|
val pivot = array[(left + right) / 2]
|
||||||
while (i <= j) {
|
while (i <= j) {
|
||||||
while (array[i] < pivot)
|
while (array[i].compareTo(pivot) < 0)
|
||||||
i++
|
i++
|
||||||
while (array[j] > pivot)
|
while (array[j].compareTo(pivot) > 0)
|
||||||
j--
|
j--
|
||||||
if (i <= j) {
|
if (i <= j) {
|
||||||
val tmp = array[i]
|
val tmp = array[i]
|
||||||
|
|||||||
Reference in New Issue
Block a user