Figured out a sort for MacOSX, hopefully it'll turn out to be useful on FreeBSD and Linux.