Google generally sorts search results by relevance. At times, it gives the option to sort by date. Sometimes people want the definitive piece of information on a certain topic and other times they just want the most recent piece of information.
A few days ago I rolled out Google Custom Search on Streetsblog as an improvement from the default WordPress search. It is a streamlined form of the Google search engine that integrates with our sites and displays results by relevance. After I rolled it out, our editors immediately realized that they wanted to be able to see search results sorted by date as well as relevance. So I set out to discover how to get Google Custom Search to sort by date.
It turns out that it wasn’t so hard. I came across this thread explaining how to do it and modified the js code accordingly. I then put an absolutely-positioned link on the search page:
The link toggles to “sort by relevance” when you are viewing results sorted by date. Google estimates the date of a particular web page to the best of its ability using content on the page, its url and the first time it was crawled. The search results appear to be “roughly” sorted by date.
Occasionally certain search results are listed higher than newer ones, perhaps when they are significantly more relevant. For example, for the search on “bike lanes”, this post was listed above this post even though it was older than it, perhaps because it had 28 comments, much more than the 4 on the more recent post.
Still, hopefully this will meet the needs of our users and help them mine the thousands of posts on Streetsblog.