Thank you for all the comments! With your help I managed to rule out a standard WordPress issue. I couldn’t find the culprit (As @DaveRomsey suggested, it could be one of the get_terms
or get_terms_orderby
hooks altering results). In any case, I solved it by sorting the array:
$searchedterms = get_terms( 'category', array(
'name__like' => $s,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true
) );
function cmp($a, $b){
return strcmp($a->name, $b->name);
}
usort($searchedterms, "cmp");