Take a look at my edit above please and use the database for your query. Also please read the documentation.
sortBy default is asc so no need to specify, there is a sortByDesc instead which accepts only the column through which you want to sort, the same for sortBy, you should have ->sortBy('company')
SQLSTATE[42000]: Syntax error or access violation: 1055 'sonic.categories.id' isn't in GROUP BY (SQL: select * from `categories` group by `company` order by `company` asc)
The company column is a string column. Should there be another way of sorting strings?
@mattb it is basically your problem. If you expect to get Categories all grouped by the Company name, you won't. So you either need to specify that you don't care which will mean select just the company from the table and group by it, or if you group by multiple columns it will be the same as if not using the Grouping at all.
So I don't even understand why would you write the company name as a text in the Category and not have a dedicated table for the companies and then use a foreign key, so it will be much easier to group categories based on their company instead of the company name.
Group by usually requires a aggregate like sum() or avg() something like this query
SELECT sum(in_stock) stock, some_field2, some_field3
FROM some_table
GROUP BY some_field2, some_field3
ORDER BY some_field1
Not knowing your data or what you expect as the result it's hard to help.
Rule of thumb don't use group by unless you use an aggregate that requires it.
In your case from the qurey you've written you might be looking to sort on more than one column.