corrected parity calculation in sort