The rituals that should be done on the day of sacrifice begin with throwing the pebbles, followed by offering the sacrifice, shaving one’s head, and performing Tawaf around the Ka`bah.
In this regard, Sheikh Sayyed Sabiq states in his well-known book, Fiqh As-Sunnah:
The rites of the 10th of Dhul-Hijjah are performed in the following order:
These rites begin with throwing the pebbles, followed by offering the sacrifice, shaving one’s head, and performing Tawaf around the Ka`bah. Observing these rites in this order is sunnah, but if one of them is performed before or after another there is no harm, according to most scholars.This is the standpoint of Ash-Shafi`i based on a hadith reported by `Abdullah Ibn `Amr who said, “The Prophet (peace and blessings be upon him) stood in Mina during the Farewell Hajj, while the people asked him questions and he answered them. A man asked, ‘O Prophet of Allah! I was not alert and I shaved my head before slaughtering my animal.’ The Prophet (peace and blessings be upon him) said, ‘There is no harm, go and slaughter your animal.’ Another man asked, ‘I slaughtered the animal before I threw the pebbles.’ The Prophet (peace and blessings be upon him) told him, ‘There is no harm. Go and throw the pebbles.'” The narrator added, “Whoever asked the Prophet (peace and blessings be upon him) about anything done before or after the other he told him, ‘No harm done. Go and do (whatever you missed).”‘
Abu Hanifah said that if someone failed to observe the proper sequence in performing these rites, and he delayed or preceded a rite, he must offer a sacrifice. He interprets the words “no harm done” of the Prophet (peace and blessings be upon him) to mean that such a person is not guilty of any sin, but nonetheless he has to slaughter an additional animal in atonement.