Kotlin Sort Array Javascript Iteration Method