Drupal Search Result Sorting in Desc order I am trying to change my Drupal site's search results. Currently it's showing the default search results by node "Updated or Changed" but i want to change it to node "Created or Published" into Descending ORDER. So all the search results will be  ORDER BY CREATED or PUBLISHED. I have looked at many files but couldn't have any success.

Which files do i have to modify and what code?

Any help will be really appreciated.

Thanks!
Similar questions here

Use hook_preprocess_search_results and set your criteria there. 

Here's the .module file you can use, this sort nodes by their creation time with a descending order. You need to create a .info file to make the module work, also remember to replace [MODULE_NAME] with your own module's name. This is not perfect but at least gives you the data in the order you want. 

&lt;?php
/**
 * Implement hook_preprocess_search_results()
 */
function [MODULE_NAME]_preprocess_search_results(&amp;$vars) {
        $results = $vars['results'];// via dsm (Devel module), we can see node creation time is available under the 'results' array
        usort($results, function($v1, $v2) {
          return $v2['node']-&gt;created - $v1['node']-&gt;created; // sort by created time, DESC order
        });
        $value = '';
        $output = '';
        $output_results = array();
        foreach($results as $item) {
          $value .= theme('search_result', array('result' =&gt; $item, 'module' =&gt; $vars['module']));
          $output_results[] = $value;
          $value = '';
        } // store all results into an array
        #dsm($output_results);
        $output = implode(" ", $output_results)."&lt;br&gt;"; // convert array to string
        $vars['search_results'] = $output;
        #dsm($vars);
}


.info file:

name = Search Desc
description = sort default search by creation date in DESC order
core = 7.x


search.tpl.php file, you need to copy this file from modules/search/search-result.tpl.php and put it under your theme dir, do not modify the original. 

&lt;?php
$info_split['date'] = date('m/d/Y - H:i', $result['node']-&gt;created);// replace update time with created time
?&gt;
&lt;li class="&lt;?php print $classes; ?&gt;"&lt;?php print $attributes; ?&gt;&gt;
  &lt;?php print render($title_prefix); ?&gt;
  &lt;h3 class="title"&lt;?php print $title_attributes; ?&gt;&gt;
    &lt;a href="&lt;?php print $url; ?&gt;"&gt;&lt;?php print $title; ?&gt;&lt;/a&gt;
  &lt;/h3&gt;
  &lt;?php print render($title_suffix); ?&gt;
  &lt;div class="search-snippet-info"&gt;
    &lt;?php if ($snippet): ?&gt;
      &lt;p class="search-snippet"&lt;?php print $content_attributes; ?&gt;&gt;&lt;?php print $snippet; ?&gt;&lt;/p&gt;
    &lt;?php endif; ?&gt;
    &lt;?php if ($info_split): ?&gt;
      &lt;p class="search-info"&gt;&lt;?php print $info_split['user'].' '.$info_split['date']; ?&gt;&lt;/p&gt;
    &lt;?php endif; ?&gt;
  &lt;/div&gt;
&lt;/li&gt;


Update:
Given Drupal's default search ranking criteria (by content relevance), an additional hook is needed inside the .module file for OP's question. After adding this, you need to go to /admin/config/search/settings and set the Influence for the 'Node Creation Date' field at the bottom of the page, re-index, and run cron. 

/**
 * Implement hook_ranking()
 */
function [MODULE_NAME]_ranking() {
  return array(
    'node_created_date' =&gt; array(
      'title' =&gt; t('Node Creation Date'),
      'score' =&gt; 'n.created',
    ),
  );
}