Only sort stages in pipeline when necessary (closes #2)