Skip to content

Instantly share code, notes, and snippets.

@5AbhishekSaxena
Last active July 15, 2022 20:21
Show Gist options
  • Save 5AbhishekSaxena/ba53b85f1ec50b4c50f4a71874cd6a6e to your computer and use it in GitHub Desktop.
Save 5AbhishekSaxena/ba53b85f1ec50b4c50f4a71874cd6a6e to your computer and use it in GitHub Desktop.
fun main() {
val numbers = arrayOf(4, 56, 12, 79, 25, 2)
sort(BubbleSortStrategy(), numbers) // Output: Numbers are sorted using Bubble sort.
sort(MergeSortStrategy(), numbers) // Output: Numbers are sorted using Merge sort.
}
fun sort(sortStrategy: SortStrategy, numbers: Array<Int>) {
sortStrategy.sort(numbers)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment