Solr按结果排序[关闭]

I have indexed a table which is giving me result like following

A
B
C
D
E
F
H
H
A
B

I want to sort result in such a manner that I get H first everytime and then rest should be sort by asc like

H
H
A
A
B
B
C
D
so on...

I am not finding a way for this. Please help.

This depends on the search query you are using in order to get the results. You could modify your query parameter so that it matches the exact result you want to be on the top, and pass the original query in q.alt parameter, and then apply the sorting you wish to use.

Note that in order to use q.alt, you need to use dismax or edismax query parser.

$alpha = array("A","B","C","D","E","F","H","H","A","B");

$first = array("H");
$alpha =array_diff($alpha, $first);
asort($alpha);
$alpha= $first + $alpha;

Demo