COmpleted triple sort