The filter handler class views_handler_filter_term_node_tid
uses the autocomplete path admin/views/ajax/autocomplete/taxonomy and is driven by the callback views_ajax_autocomplete_taxonomy()
.
This autocomplete callback explicitly excludes the term typed in and doesn't do any explicit sorting (thus defaults to whatever your RDBMS does):
$query = db_select('taxonomy_term_data', 't');
$query->addTag('translatable');
$query->addTag('term_access');
// Do not select already entered terms.
if (!empty($tags_typed)) {
$query->condition('t.name', $tags_typed, 'NOT IN');
}
// Select rows that match by term name.
$tags_return = $query
->fields('t', array('tid', 'name'))
->condition('t.vid', $vid)
->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
->range(0, 10)
->execute()
->fetchAllKeyed();
If you'd like to alter the results or how it's sorted, the query is using tagging, thus available for altering via hook_query_alter()
.