'sort' implementation (Bug 27933) - any easy way?