Ignoring ‘a’ when sorting posts

That’s because you are matching from the fourth character as it was supposed to be used only with “the ” (three characters onwards). Then the author of article added an “an ” which has a similar effect. I think he didn’t test for “a ” after all.

Your code matches this:

Horror of Party Beach

hort Film

Horton

horus Line

See:
THEN trim(substr($wpdb->posts.post_title from 4)

You should use a regex to trim the trailing A|AN|THE as well or even sort them using PHP.