Sorting arrays and reinventing wheels for a good cause

Have you ever felt like wirintg a function in PHP that the language already has internally? Sure you have! We all have, we are PHP developers. It’s called re-inventing the wheel and all of us do it at one point or another in our career.

Over on his blog “Zend Framework Blog“, Richard Knop has bee doing just this by writing routines to sort arrays. Actually, this is a great idea because he is showing how to implement several CS standard sort routines in PHP. Here are the routines he’s written so far.

I do not get the impression that Richard actually expects people to use these routines. The focus of the articles seems to be just showing how they can be implemented in PHP. Obviously, any code running in userland is going to be orders of magnatude slower than native code. That having been said, understanding these routines has helped countless CS majors over the years.

Whether you want to re-live your CS glory days or just learn from someone else learning, these short and code filled posts are worth taking a look at.

About Cal Evans

Many moons ago, at the tender age of 14, Cal touched his first computer. (We're using the term "computer" loosely here, it was a TRS-80 Model 1) Since then his life has never been the same. He graduated from TRS-80s to Commodores and eventually to IBM PCs.   For the past 10 years, Cal has worked with PHP and MySQL on Linux OSX, and when necessary, Windows. He has built on a variety of projects ranging in size from simple web pages to multi-million dollar web applications. When not banging his head on his monitor, attempting a blood sacrifice to get a particular piece of code working, he enjoys building and managing development teams using his widely imitated but never patented management style of "management by wandering around". Cal is happily married to wife 1.33, the lovely and talented Kathy. Together they have 2 kids who were both bright enough not to pursue a career in IT. Cal blogs at and is the founder and host of Nomad PHP