Refactor parameters in table sort helper