Could someone explain to me how the anger of the Lord is turned by hanging people in view for all to watch? 

Numbers 25:4 (Mechon-mamre translation): "Take all the chiefs of the people, and hang them up unto the LORD in face of the sun, that the fierce anger of the LORD may turn away from Israel" 

How does such an image reverse the anger of the Lord that flared up because of the sin of those who adventually would be hanged.