Refactor to do sorting in recipe instead of in template