From my understanding, most states foreclosure sale is subject to any and all superior liens and wipes out any all junior liens. Tax liens from the IRS or State and Local government always take the high priority position. The first mortgage is higher than the second, and HOA liens are usually lower than mortgages.
Here are some other things I have learned that may help you regarding Foreclosure sales.
1) Since Tax liens are superior to all other liens, assessments, charges, etc., tax foreclosures generally wipes out all liens on the property.
2) The Notice of Foreclosure Sale is required to be publicly posted and published. In Judicial foreclosures (mortgage), it will state something along the lines of "Under and by virtue of the power of sale contained in a certain Deed of Trust." It it is a lien foreclosure it will not state that.
3) Not sure if this applies to your county, but in mine this is a BIG ONE: If the Notice of Foreclosure Sale states "This sale is made subject to all prior liens, unpaid taxes, any unpaid land transfer taxes, special assessments, easements, rights of way, deeds of release, and any other encumbrances or exceptions of record". (emphasis added). Any other encumbrances or exceptions of record means ANY other liens - including junior liens. You want it to state "Prior" instead of "Any"