I live in the Middle East and have acquired my English skills orally and from experience rather than academically, and there's a certain structure that English-speaking people in my vicinity use often.
In a sentence like:
'John was troubled by something but I didn't know what it was/what was it.'
From experience, I feel that 'what it was' is correct but I don't know why and most nonnative speakers would use the other construction. Can somebody explain or at least tell me what topic in a grammar book would deal with this kind of structure so I could read about it?