Ensure stable sorting in MutableList.sort/sortWith

MutableList.sortWith now works correctly in JS_IR backend too

#KT-12473
This commit is contained in:
Ilya Gorbunov
2019-01-16 02:17:34 +03:00
parent 7191624a92
commit 56672c2564
7 changed files with 49 additions and 19 deletions
@@ -109,8 +109,7 @@ private fun <T> collectionsSort(list: MutableList<T>, comparator: Comparator<in
if (list.size <= 1) return
val array = copyToArray(list)
array.asDynamic().sort(comparator.asDynamic().compare.bind(comparator))
sortArrayWith(array, comparator)
for (i in 0 until array.size) {
list[i] = array[i]