umbraco/Umbraco-CMS — pull request #591 by AndyButland (2014-12-13 21:32:48+00:00)
Title: U4-6003 - Enabled sorting for custom columns on list view

With the current implementation of the list view you can only sort by system columns (Name, SortOrder etc.) and not custom columns you have added to your document types. This PR allows that.

Couple of points to note for review of what I've done so far:

- The crux of it is a sub-query added to the ORDER BY clause when we are ordering by a custom field. This looks up the field's value from the most recent content version. Have a slight performance concern about this - sub-queries in SELECTs and ORDER BYs not being the most efficient. But it's still one database hit and not a return to the true N+1 query this was doing a few months back. So think you'd need a lot of child nodes before this was an issue in practice.
- SQL has been written for SQL Server. My guess is it won't work as is for MySQL, so if you can direct to any pointers for how these syntax issues are handled would be happy to look further that that.
- GetPagedResultsByQuery() in VersionableRepositoryBase was previously doing an ORDER BY in SQL and then repeating this via LINQ to Objects. I couldn't see that this second ordering was necessary so removed it, but wanted to flag here in case I've missed something around why this was necessary.
- The last two commits you could pull in separately, small amends to fix and hide respectively sorting on a couple of the default columns for the member list view