Enough people who can't code apply for software development jobs that asking a simple thing like "Write a sort function" is a good filter. Why waste 10 minutes on a better question when he can eliminate 50% of the applicants in 2? The interviewer doesn't think you're dumb and he's not trying to snub you - it's just how interview questions work.
If you're such an amazing developer you shouldn't have a hard time writing a sort function. Spend the 30 seconds to write the sort routine and get over it.
True story, i know a guy who was denied a job at FB after an interview, a few months later they ended up giving him a few hundred thousand after they acquired the small company he ended up working for. He now works for FB.
Interviews are poor indicators of performance.