# Context-Free Grammar construction when order isn't specified

I'm having trouble constructing a grammar for

L={wϵ{a,b}|na(w)≠nb(w)}

So I need to construct a grammar for the language wherein the number of a's does not equal the number of b's. The farthest I've attempted is splitting the language into

L={wϵ{a,b}*|na(w)>nb(w)}∪{wϵ{a,b}*|na(w)<nb(w)}

but I don't know where to go from there. What makes this problem challenging is that no order is specified so I don't even know where to begin.

Thus, the second part of my questions is if there is any general rule I should follow when dealing with languages that don't stipulate an order.

-

Hint: The first step in your grammar should decide whether $n_{\mathtt{a}} > n_{\mathtt{b}}$ or $n_{\mathtt{a}} < n_{\mathtt{b}}$, and then the two "halves" of your grammar will then construct appropriate strings. This related question might help you.