partition algorithm