Synchronising a generator for connection to a network or to another generator with means for ensuring correct phase sequence