Functions for sorting on data

References and closes #127