Implement zhen's version of sorting