The pasuk (Tehillim 114:3) tells us that at Kriyas Yam Suf, "the Sea saw and fled."
It seems that the Sea would not split until it saw something. The Medrash explains: What did it see? It saw Yosef's coffin. Just as Yosef ran away from Potiphar's wife, so too, the Sea split" (Mechilta D’Rabbi Yishmael 14:15; Bereishis Rabbah 87:8; Midrash Tehillim 114).
The Maharal asks the question slightly different: Why did sea go against its natural order and by splitting? Because Yosef overcame his nature to flee the house of Potiphar and refrain from sinning" (Gevuras Hashem, chapter 40).
Yet, the Medrash (Shemos Rabbah 21:8) says that it was in the merit of Avraham that Hashem split the sea for the Jews.
In whose merit did the sea split: Yosef or Avraham?