Custom sorting script

Is it possible to implement a custom sorting algorithm, for example in a hook script?

Referring to the Hooks page: Hook scripts - Funnelback Documentation - Version 15.24.0

My understanding is that sorting is done in the Query Processor. Is pagination (num_ranks/start_rank) also done here?
If so, I suppose it’s not possible to sort the full list of results, just the current page?

That’s correct - you can use a hook script to custom sort your results, but only the page of results that is returned.

You can’t custom sort the full set of results unless you run a query that returns everything (and this isn’t feasible unless you have a very small set of results).

If your custom sort is known in advance and always going to be the same you could generate a sort key and add this as a hidden metadata field using a filter, then use your metadata sorting to sort by this field alphabetically (same instructions as per the KB article that outlines how to sort by multiple keys). Redirect Notice

Thanks for confirming Peter.

Yes I forgot to mention, we were planning to generate a sort key, but then realised we’d have to do this on many collections, including two large push collections. As far as I’m aware, we’d have to re-push every single item to add the new metadata, which in our case would be risky and high effort.