It depends upon several things. First, when you say "pending lawsuit," I assume you mean a lawsuit that had been filed and was pending final judgment. Second, I must assume the suit and the TRO itself had to do with the foreclosure. Next, we have to assume that the TRO was still in effect at the time of the foreclosure sale, that it was directed to (perhaps among others) the foreclosing lender (and hence, a trustee acting at the lender's direction), and that the lender had either actual or constructive notice of the TRO.
If all these assumptions are more or less correct, you have a strong case for setting aside the trustee's sale and, obviously, a strong defense for the UD suit.
Since most lenders and trustees would know better than to act in violation of an applicable TRO, I have to wonder if maybe lack of notice of the TRO is an issue here. Also, it could be a problem for you if the lawsuit was of a type where recording, filing and serving a Notice of Pendency of Action (lis pendens) was required.
These are deep and muddy waters for a self-represented person. Under the circumstances as described, someone has made a major mistake. It may be the lender, but it could be your attorney, or you.