Fixed sorting thanks to @moollaza's debugging magic.