The sheriff did not break the law, he was enforcing it. The judges issued partisan judgements.
Profiling is a great tool. If you have a band of pitbulls illegally loose biting people, are you going to round up leashed, licensed poodles? No You are going to examine every pit bull to see if they are leashed and licensed.  Common sense. 
If the Latinos in that state felt they were unfairly targeted, perhaps they should have helped clean up the mess by telling their illegal relatives and neighbors to go home.