One of my refinement lists, Designer, has about 250 items in it.
It’d be great if I could display the designers that I know are popular at the top of the list (say 6 designers) followed by a breaker, then the remaining designers beneath it in alphabetical order.
By “popular”, I don’t mean the ones with the most records/results against them. It is just the designers that I know are popular with our users based on website stats, emails received, social media comments/likes. It would be a static list of 6 designers that I could maintain manually.
- Checks if both a & b exist in popularDesigners - if they do, then compare the two using their index within the popularDesigners array
- If only item a is in popularDesigners, rank it higher than b
- If only item b is in popularDesigners, rank it higher than a
- If neither a nor b are in popularDesigners, do a standard string comparison (e.g. a.name < b.name)
- Specified the compareFunction as the sortBy parameter in the refinementList widget initialisation
This does the job, but by my calculation takes 350-400ms to run. I don’t think adding almost half a second to the page load time to provide this functionality is worth it. It will get even slower as the # of designers in the refinementList grows.
But the question is, how would you go about it? Is there a completely different/better way of doing it? Or should I be focusing on optimising the compareFunction?