This says more about the arbitrary nature of using city boundaries for studying home pricing than anything else. San Francisco certainly has high prices, but it also has one of the smallest footprints of any major city, and has lots of nearly-indistinguishable residential areas that are adjacent but fall outside its boundaries, particularly to the South and East. If you look just at pricing within the city boundary, it's going to be inflated by the fact that such a large percentage of that area is still relatively close to the "city center" and benefitting from the value that creates.
Meanwhile, "New York City" (which ranked lower on median price) includes large residential expanses that are much further away from the city center, including Staten Island. (Not to mention Los Angeles, which is what, 50X the size of SF proper?)
I'd like to see this comparison done for say, Manhattan island vs. San Francisco - that would be a much more apples-to-apples compare.