reverse an array in place