[JS IR] stdlib: Use comparator in CharArray.sort
CharArray is represented as a regular JS Array. Its default sort order is based on string representation of elements.
This commit is contained in:
@@ -1303,7 +1303,7 @@ public actual fun FloatArray.sort(): Unit {
|
|||||||
* Sorts the array in-place.
|
* Sorts the array in-place.
|
||||||
*/
|
*/
|
||||||
public actual fun CharArray.sort(): Unit {
|
public actual fun CharArray.sort(): Unit {
|
||||||
this.asDynamic().sort()
|
this.asDynamic().sort(::primitiveCompareTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1038,7 +1038,13 @@ object ArrayOps : TemplateGroupBase() {
|
|||||||
body { "definedExternally" }
|
body { "definedExternally" }
|
||||||
}
|
}
|
||||||
on(Backend.IR) {
|
on(Backend.IR) {
|
||||||
body { "this.asDynamic().sort()" }
|
if (primitive == PrimitiveType.Char) {
|
||||||
|
// Requires comparator because default comparator of 'Array.prototype.sort' compares
|
||||||
|
// string representation of values
|
||||||
|
body { "this.asDynamic().sort(::primitiveCompareTo)" }
|
||||||
|
} else {
|
||||||
|
body { "this.asDynamic().sort()" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
body {
|
body {
|
||||||
|
|||||||
Reference in New Issue
Block a user