Multi-threaded quicksort! In PHP!

Yeah! In PHP!

Why would you do this?

Well, I went to a PHP meetup presenting some common implementations and comparing them to the speedy native PHP implementation of sort() and related functions.

I figured that while efficient sorting isn’t the most common use case for PHP – and in a web context you often don’t want to let each user spin up numerous threads – for command line cases this approach should be able to provide a real performance boost.

In particular, the already-PHP-favoured quicksort algorithm works with a divide and conquer approach that should be perfectly suited to divvying up work between threads.

Continue reading