Whatever I said in my last answer is correct, but there needs to be some addition. Here I am trying to explain your question. My first impression was that out of the two quoted example sentences in the original post only one was correct. But after going through the comment of @DamkerngT. I am sure both of the example sentences are correct.
Consider the following example -
Mr A is my friend.
Now if I want to make this sentence interrogative it will be - Who is
my friend? The subject is Mr. A. Similarly Mr. A can be the object of
the sentence having the same meaning - My friend is Mr. A. And now if
we make this sentence interrogative the inversion occurs - Who is my friend?
Your example sentence is not an interrogative one, instead an assertive sentence. So the depending clause also will be assertive.
I know Mr. A is my friend. - I know who is my friend. ( When we make "Mr. A is my friend" interrogative, no inversion occurs. So "I know who is my friend" here also no inversion will occur.)
I know my friend is Mr. A - I know my friend is who - I know who my friend is. ( When we make "My friend is Mr. A" interrogative, inversion occurs - Who is my friend. To make "who is my friend" assertive we inverse again. So it comes down to - I know who my friend is.)
I know this answer is a little bit clumsy, but I didn't find any other way to explain it.
Please let me now after reading this answer what all clarification you need.