The check for metadata "orgname" is wrong so the sort link is incomplete:
SELECT COUNT(*) AS `Rows`, `type` FROM `table` GROUP BY `type`
If a query contains an ORDER BY without the table name there are no sort-arrows:
SELECT COUNT(*) AS `Rows`, `type` FROM `table` GROUP BY `type` ORDER BY `type`
better solution
Why did you remove strlen($fields_meta[$i]->table)?
Also some comment what does the if actually do would be welcome.
I replaced "isset && strlen" by "!empty"...
And my "if" adds the name of the table to the compare-string if it is not already in it.
Some time ago we replaced the "! empty" syntax with "strlen()" to catch the case of a table name "0".
Well then both have to be "strlen"...
The "isset" is not neccessary - it can only have a length if it is set...
Updated
If $fields_meta[$i]->table is not set, you get a notice if you call strlen() on it.
Ok, I updated my patch...
updated
Merged in subversion, thanks.