So I feel like I must be missing something obvious, but I can't find a solution to my situation. I'm trying to sort some nodes by the chosen taxonomy term name. This is Drupal 7, Views 3.
I have a taxonomy vocabulary 'Country' that is setup something like:
Asia --Bangladesh --India --Vietnam Afria --Algeria --Libya --Nigeria
On the content type ('Partners') I have a taxonomy field called field_country. I happen to be using the Hierarchical Select module to make sure that, for this field, only the deepest levels are chosen (countries, not regions).
So all of that works and I can display the country chosen as a field in the view.
But I can't seem to figure out the correct way to sort by that country name. When I add the field_country field to the sort criteria, the ordering doesn't make sense. When I check the SQL statement it actually shows that it is sorting by field_data_field_country_field_country_tid. So it seems to be sorting by the tid rather than the actual term value. Although, a quick scan of the tid values shows that it isn't even sorting correctly by tid!
Here is what the SQL looks like:
SELECT DISTINCT node.nid AS nid, node.title AS node_title, field_data_field_country.field_country_tid AS field_data_field_country_field_country_tid, 'node' AS field_data_field_location_node_entity_type, 'node' AS field_data_field_country_node_entity_type, 'partners:block' AS view_name FROM {node} node LEFT JOIN {field_data_field_country} field_data_field_country ON node.nid = field_data_field_country.entity_id AND (field_data_field_country.entity_type = 'node' AND field_data_field_country.deleted = '0') WHERE (( (node.status = 1 OR (node.uid = 1 AND 1 0 AND 1 = 1) OR 1 = 1) AND (node.type IN ('partner')) )) ORDER BY field_data_field_country_field_country_tid ASC LIMIT 9 OFFSET 0
Any suggestions? Is there a magical relationship I have to activate to get the correct sort option available?
Thanks!