I am looking for a flexible way of sorting the results from a search in a Habitat structured solution. I tried different approaches but couldn't find one that doesn't need a hardcoding way of doing things.
Let's say I have to sort by some types like 'Date' and 'Title', both can be ascendant and descendant. Since a solution contains multiple page types, like News, Events, Articles, Publications, each of this could have its own project in solution and has its own fields in Sitecore to sort on, example on News you would have 'Date', on Events would be 'Start Date', on Articles could be 'Updated Date' on Publications could be 'Release Date' and so on.
I am looking for a way I could define these in that specific project, and then by using the Foundation.Indexing project to dynamically sort each depending on type and on sort params I send.
I am doing this on a Sitecore Habitat structure and trying to make it flexible enough so if I add later new projects I don't need to modify the actual search but extend it in the added project. I have tried different ways of doing it but haven't managed so far without having to hardcode some field names or instances that would make me do changes each time I add new projects to the solution.
If anyone has any idea how could this be done in a nice and flexible way let me know. I am eager to find out if anyone ever tried something like this on Habitat and managed to have it done in a good pro way.