Adding sorting infrastructure