Rebuild of sorting algorithm

Added modular sorting to separate the function into information
gathering and information processing. Also creates the option for a
rudimentary API