Psalm 7:8: The LORD shall judge the people: judge me, O LORD, according to my righteousness, and according to mine integrity that is in me.
I have had a hard time with that verse in the past. God forbid that I were to be judged according to my own righteousness - which is as a filthy rag. I need the righteousness of Jesus, or else I am without hope at the judgment.
So, when I see David say "judge me according to my righteousness," I am always taken back by that. I don't perceive David as being so arrogant as to think that he has enough righteousness to ask God to judge him according to it. David is the guy that said, Behold I am shapen in iniquity, and in sin did my mother conceive me.
What then does David mean when he says that phrase or similar phrases throughout the Psalms? Well, I think it has to do with the same idea as the signers of the Declaration of Independence had. After introducing the Declaration, and listing the grievances that they had against the king of England, they have a conclusion paragraph, in which is stated:
"We, therefore, the Representatives of the united States of America, in General Congress, Assembled, appealing to the Supreme Judge of the world for the rectitude of our intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly publish and declare, That these united Colonies are, and of Right ought to be Free and Independent States"
They were saying, "God, we are going against the king of England for just reasons. We are separating from their power. We appeal to You, to judge if our intentions are right." They recognized that they were not only declaring independence, but also declaring war at the same time. They appealed to God to give them victory in the war if their actions were right. In a sense, they were saying, "God, judge us according to our righteousness."
Next time you read David talking about how he is just, and asking God to judge him accordingly, I think you'll find that he is not asking for God to judge his eternal life based on his own righteousness, but rather, for the temporal task and enemy at hand.
Just a thought...