Refacto sort infra