Outline:

God's King Faces... 

... desertion (v1 - 2) yet trusts in God's salvation (v4 - 5)

... derision (v6 - 8) yet trusts in God's salvation (v9 - 11)

... defeat (v12 - 18) yet trusts in God's salvation (v19 - 21)

So God's King Sings of God's Victory... 

... to His people (v22 - 26)

... to the nations (v27 - 31)