Skip to content

Instantly share code, notes, and snippets.

@5AbhishekSaxena
Last active July 11, 2022 08:57
Show Gist options
  • Save 5AbhishekSaxena/cc0c5c1afd01030ed2ebbfbc1152a0f3 to your computer and use it in GitHub Desktop.
Save 5AbhishekSaxena/cc0c5c1afd01030ed2ebbfbc1152a0f3 to your computer and use it in GitHub Desktop.
fun main() {
val numbers = arrayOf(4, 56, 12, 79, 25, 2)
sort("Bubble", numbers)
}
fun sort(algorithm: String, numbers: Array<Int>) {
if (algorithm == "Bubble") {
println("Numbers are sorted using Bubble sort.")
// bubble sort algorithm
} else if (algorithm == "Merge") {
println("Numbers are sorted using Merge sort.")
// merge sort algorithm
} else {
throw IllegalArgumentException()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment