Mundane Orders of Precedence

This is unlikely to come up in my current saga, but I've become a bit curious about orders of precedence in mundane politics. I'm okay with the various scales of nobility, but I'm curious to know where clergymen fit in.

Exampli gratia: a duke and a cardinal are attending a banquet (let's say it's a feast at the Imperial court, to explain why two such great men are attending). They're both extremely powerful. They're both entitled to be addressed as 'your grace'. Who gets seated closer to the Emperor?

I guess the Cardinal should, as it represents the Church. However it looks like a political question: who does the emperor want closer to him? How good is emperor relationship with papacy?

Simply put the Cardinal on the left of the Emperor and the Duke on his right :mrgreen:

It varies depending on the court and the period. The "Manual of Heraldry, 5th edition" gives, for example: