Refactor sorting logic in movies view