The one at the top is correct! This has been the cause of much grief and confusion. Unfortunately I can't say for certain where the wrong one came from because I re-used the connector on a 'generic' O2 sensor from eBay, but the things I do know are:
I swapped the wires over and it now works.
I bought an 'aftermarket' sensor from Rimmers and sent it back because it didn't work.
Now it gets a bit hazy:
I think Rimmers sent me another one and that didn't work either so I gave up with them and bought the eBay one. I can't say for certain the the wrongly wired connector came from the second Rimmer's sensor but it fits with the evidence. The car was running fine so it seems unlikely that the wrongly wired one was ever working properly on the car.
P.S. I'm putting this in a new thread in case anyone else has just bought a new sensor that doesn't work.