Refactors sorting for Action template