Question

Here is the code of sphinx

    $sphinx_results = clone $this->sphinx;

    //Select Columns
    $sphinx_results->SetSelect($col . ', @count'); //Select cols

    //Group results
if($col=='province')
{
    $sort_str = ($sort_str === FALSE) ? $col.' asc' : $sort_str; //Get sort string
    }
else
$sort_str = ($sort_str === FALSE) ? '@count desc' : $sort_str; //Get sort string
$sphinx_results->SetGroupBy($col, $sphinx_results::SPH_GROUPBY_ATTR, $sort_str);

    //Perform Query
    $results = $sphinx_results->Query( $this->keyword, 'autoandt_www' );

I wanted to select 10 provinces with maximum count and i wanted to this result in alphabetical order of provinces. How to accomplish this in php sphinx. I am using kohana framework.

No correct solution

OTHER TIPS

The easiest way is to just get the top 10 results from sphinx - which it looks like you already have that in your code.

Then in the application resort them into alphabetical order. Pretty trivial in most languages. within PHP the uksort function is nice. But no idea if kohana provides any sort of convenience function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top