Right, priority was 1..5 where 5 was a higher priority. So “order by priority” delivered priority=1 items first, and processed them in that order, which was the opposite of what I wanted.
It was absolutely my mistake, but “order by priority” reads so well in English, so my eye just couldn’t see the mistake.
I mean I’d been programming for decades at that point, I knew the syntax, I know our data model, I stared at the code and I still couldn’t see it. (Eventually I did see it of course..)
Since then I’ve been of the belief it would be better if SQL forced you to put “asc” or “desc” when using “order by”. Then you’d be forced to think about it.
So I was agreeing with the previous poster, who said that defaults aren’t always a good idea.