Added/refined new sort utility functions.