diff --git a/src/com/freaklius/kotlin/algorithms/sort/EstouComSort b/src/com/freaklius/kotlin/algorithms/sort/EstouComSort new file mode 100644 index 0000000..7125541 --- /dev/null +++ b/src/com/freaklius/kotlin/algorithms/sort/EstouComSort @@ -0,0 +1,7 @@ +fun > estouComSort(list: List): List = list.let { + if (it.windowed(2).all { a -> a[0] < a[1] }) + it + else + it.toMutableList() + .apply { this.shuffle() }.let { sort(it) } +}