Using db_select, how can I select all nodes with any of an array of taxonomy terms and order by the number of terms it is associated with?
You should put count as alias name in the count(*) and then groupby clause can be used on that column.

$query = db_select('node', 'n')
      -&gt;fields('n', array('nid'));
$query-&gt;addExpression('COUNT(n.nid)', 'count'); // addExpression
   $query-&gt;condition('n.type', 'post')
      -&gt;condition('n.status', 1);
    $query-&gt;join('field_data_field_tags', 'tags', 'tags.entity_id = n.nid');   
    $query-&gt;condition('tags.field_tags_tid', $tags, 'IN');
    $query-&gt;groupBy('count', 'DESC'); //count is column name given in the addExpression