Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 17607)
+++ wp-includes/query.php	(working copy)
@@ -2148,9 +2148,11 @@
 				preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches);
 				$q['search_terms'] = array_map('_search_terms_tidy', $matches[0]);
 			}
+			$q['search_terms'] = array_filter( (array) $q['search_terms'] );
+
 			$n = !empty($q['exact']) ? '' : '%';
 			$searchand = '';
-			foreach( (array) $q['search_terms'] as $term ) {
+			foreach ( $q['search_terms'] as $term ) {
 				$term = esc_sql( like_escape( $term ) );
 				$search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";
 				$searchand = ' AND ';
@@ -2345,7 +2347,19 @@
 			if ( empty($q['orderby']) )
 				$q['orderby'] = "$wpdb->posts.post_date ".$q['order'];
 		}
+		
+		// Order search results by relevance
+		if ( !empty( $q['search_terms'] ) && empty( $q['exact'] ) ) {
+			$orderby_search = array();
+			foreach ( $q['search_terms'] as $term ) {
+				$term = esc_sql( like_escape( $term ) );
+				$orderby_search[] = "$wpdb->posts.post_title LIKE '%$term%'";
+			}
+			$orderby_search = implode( ' OR ', $orderby_search );
 
+			$q['orderby'] = "($orderby_search) DESC, " . $q['orderby'];
+		}
+
 		if ( is_array( $post_type ) ) {
 			$post_type_cap = 'multiple_post_type';
 		} else {
