public function sortSearchResults($results, $term)
    {
        $sortedResults = [];

        if (!empty($results)) {
            foreach ($results as $result) {
                if (stripos($result->getTitle(), $term) !== false) {
                    array_unshift($sortedResults, $result);
                } else {
                    $sortedResults[] = $result;
                }
            }
        }

        return $sortedResults;
    }
public function sortSearchResults($results, $term)
    {
        $sortedResults = [];

        if (!empty($results)) {
            foreach ($results as $result) {
                if (stripos($result->getTitle(), $term) !== false) {
                    array_unshift($sortedResults, $result);
                } else {
                    $sortedResults[] = $result;
                }
            }
        }

        return $sortedResults;
    }
public function sortSearchResults ( $ results , $ term ) { $ sortedResults = [ ] ; if ( ! empty ( $ results ) ) { foreach ( $ results as $ result ) { if ( stripos ( $ result -> getTitle ( ) , $ term ) !== false ) { array_unshift ( $ sortedResults , $ result ) ; } else { $ sortedResults [ ] = $ result ; } } } return $ sortedResults ; }
Sort search results by giving priority to founded by title.

@param array  $results
@param string $term

@return ArrayCollection
Sort search results by giving priority to founded by title .