News for hackers. Stuff that matters.
Re:Visualizing and exploring sorting algorithms in two dimen... by sorokod on Saturday July 27, 2019 @12:40PM (#20542778)
> Quicksort is a mouthful to explain in detail

Don't know about that, this is not efficent but "explains" quicksort in general:

    fun <T : Comparable<T>> quickSort(list: List<T>): List<T> =
            with(list) {
                if (size < 2) this
                else {
                    val pivot = first()
                    val (smaller, greater) = drop(1).partition { it <= pivot }
                    quickSort(smaller) + pivot + quickSort(greater)
                }
            }

There are no comments on this comment yet.