reversing an array in place