Issue #401: Add a generic sorting function.
Merge pull request #514 from quicksketch/401/generic_sort

Issue #401: Add a generic sorting function.