Initial work on setting up sorting

Helper functions done, basic sorting working, need to test and check robustness
Recursive sorting completed
Merge branch 'feature/sorting' into develop