So it is that one of the characteristics that the sperm whale shares with all cetaceans is that it swims by flexing its tail flukes dorso-ventrally, a less efficient way of swimming than that of its distant piscine ancestors, but a mode of locomotion that derives directly from the galloping of its more recent terrestrial ones.
Source: wiktionary