Skip to content

Instantly share code, notes, and snippets.

@Alesh17
Last active May 26, 2021 13:12
Show Gist options
  • Save Alesh17/2af261d7c3c629018f3503cdeca0f9c1 to your computer and use it in GitHub Desktop.
Save Alesh17/2af261d7c3c629018f3503cdeca0f9c1 to your computer and use it in GitHub Desktop.
fun bubbleSort(list: MutableList<Int>) {
    do {
        var isSorted = true
        for (i in 1 until list.size) {
            if (list[i] < list[i - 1]) {
                val temp = list[i]
                list[i] = list[i - 1]
                list[i - 1] = temp
                isSorted = false
            }
        }
    } while (!isSorted)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment