Forums

Sort Algorithm

BigCol 18 Jan, 2018
Hello,

How would you suggest approaching a sort algorithm for search results / outputs beyond simply sorting by a given field? My form will be querying & filtering a directory based on a dozen inputs and I would like the end output to be sorted by relevance to a weighting of the various inputs rather than a single variable.

Is there a way to calculate a relevance score in the background, for each of the directory listings, as a function of the inputs?

Thanks for any help or guidance you can offer. Feel free just to point me in the right direction and I'll explore the options. I don't have a coding background but am pretty handy at figuring these things out.

Cheers,

Colin
GreyHead 19 Jan, 2018
Hi Colin,

ChronoForms does not directly support this - nor does ChronoConnectivity which is the 'listing' extension that you probably need here,

You are going to need to work out the exact logic of your weighting and you may then be able to specify that as a calculated data item in you MySQL query, or possibly using PHP to sort a data array loaded from your tables.

NB This is not a trivial task!

Bob
BigCol 19 Jan, 2018
Hi Bob,

So the end result that I'm querying the database for an array of (Image, Title, [calculated data item] ) with the results sorted by the calculated data item.

Pardon the newbie question, but where in CF or CC do I put the SQL query?

Thanks again,

Colin
This topic is locked and no more replies can be posted.