title: Sort Google Custom Search Results by Date
body: <p>I'm in the middle of migrating Google Custom Search Engine to use the CustomSearchControl to replace the deprecated WebSearch API, and one of the requirement is to sort the suggestion results by date. But so far, I couldn't figure out how to tell Google to sort results by latest date before returning the suggestion. The sample code is as follows:</p>
  
  <pre><code>var refinement="Support";
  .....
  switch(product)
  {
      case "10000":
          refinement = "Support1";
          break;
      case "10002":
          refinement = "Support1";
          break;
      case "10001":
          refinement = "Support2";
          break;
      default:
          break;
  }
  
  var customSearchControl = new google.search.CustomSearchControl('cseId');
  customSearchControl.setSearchStartingCallback(this, function(control, searcher, query) {
      searcher.setQueryAddition('more:' + refinement);
  });
  
  customSearchControl.setResultSetSize(7);
  customSearchControl.draw('entries');
  ......
  </code></pre>
  
  <p>I've tried the recency label to sort the results, but it doesn't work:</p>
  
  <pre><code>customSearchControl.setSearchStartingCallback(this, function(control, searcher, query) {
      //searcher.setQueryAddition('more:recent3');
      searcher.setQueryAddition('more:' + refinement + ', more:recent3');
  });
  </code></pre>
  
  <p>And I also tried sorting by attributes but it's not working either:</p>
  
  <pre><code>var options = {};
  options[google.search.Search.RESTRICT_EXTENDED_ARGS] = {'sort': 'date-sdate:d:s'}; //Tried to use other date format but it doesn't help
  
  var customSearchControl = new google.search.CustomSearchControl('cseId', options);
  </code></pre>
  
  <p>Perhaps sorting by attributes will not work because we don't have  attributes declared in our web documentations. Thus, is there any other way that allows us to tell Google to sort the search results by date?</p>