refactored sorting logic in path URL in view and accessing params in controller