color sort reimpl