Partition algorithm for COMP 400 class @ McGill.