I've had to write my own sorting algorithm perhaps twice in the last some-odd years. If you're writing sorting algorithms from scratch, you probably should sit back and consult your standard libraries.
So if I ask a candidate some basic coding question and he can't write a for loop, I know it's a no-hire. But past that basic bar, sifting apart the good candidates from the great ones is actually very hard. Do we continue to ask these questions because we can't do better?
(That's why I ask algorithm questions. I realize they suck, but I just don't have any better ideas. I'm an engineer, not an HR flack.)
So what's a better way to test a programmer candidate?