-
-
Save SanjayDevTech/4afc3fa1886bf48060d3599f09e779f6 to your computer and use it in GitHub Desktop.
Kotlin sort list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val elements = mutableListOf(51, 21, 32, 41, 0, 10, 2, 7) | |
for (i in 0 until elements.size) { | |
for (j in 1 until elements.size) { | |
if (elements[j-1] > elements[j]) { | |
val temp = elements[j] | |
elements[j] = elements[j - 1] | |
elements[j-1] = temp | |
} | |
} | |
} | |
println(elements) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment