function search_api_glossary_sort_glossary in Search API AZ Glossary 7.2
Same name and namespace in other branches
- 7.3 search_api_glossary.module \search_api_glossary_sort_glossary()
- 7 search_api_glossary.module \search_api_glossary_sort_glossary()
Sorts by A-Z then 0-9 and then # weight.
1 string reference to 'search_api_glossary_sort_glossary'
File
- ./
search_api_glossary.module, line 230 - Search api glossary module file.
Code
function search_api_glossary_sort_glossary(array $a, array $b) {
$a_value = isset($a['#indexed_value']) ? $a['#indexed_value'] : '';
$b_value = isset($b['#indexed_value']) ? $b['#indexed_value'] : '';
if ($a_value == $b_value) {
return 0;
}
elseif (ctype_alpha($a_value) && ctype_alpha($b_value)) {
return $a_value < $b_value ? -1 : 1;
}
elseif (($a_value == "#" || $a_value == "0-9") && ctype_alpha($b_value)) {
return 1;
}
elseif (ctype_alpha($a_value) && ($b_value == "#" || $b_value == "0-9")) {
return -1;
}
elseif ($a_value == "#" && $b_value == "0-9") {
return 1;
}
elseif ($b_value == "0-9" && $a_value == "#") {
return -1;
}
}