Alg of sort