moves sorting logic from service into directive's controller for better encapsulation