Clean up some of the ugly angular we have for sorting

I know we've got some duplicated functions across the controllers now, I'm not 100% sure how to define a service so that the two methods can be made common but still have access to the controller's scope.  I'll try look into this next.