Sorting Agents Based on Primary Market Position

TLDR Saahiththiyan wants to sort agents based on their primary_market position, but Kishore Nallan suggests it's not possible server side and recommends a client side solution.

Powered by Struct AI
Mar 21, 2023 (6 months ago)
Photo of md5-9f3e78583a1ff31273cfc64283b0981e
01:20 AM
Hey guys,
I have a collection called agents, each agent in that index can have primary_market.
Example, for an agent called Jack primary_market: [Sydney-NSW-2000-Australia, Pots-Point-NSW-Australia], For an agent called Bill primary_market: [Pots-Point-NSW-Australia, Sydney-NSW-2000-Australia]
When i filter for agents using the slug Sydney-NSW-2000-Australia i want to have Jack on top of the results based on the position of the slug inside the primary_market and Bill to be at the bottom of the results.
Basically i want to sort the results based on the position of the slug i am filtering by inside the primary_market array.
Likewise if i filter for agents using the slug Pots-Point-NSW-Australia i want Bill to be at the top of the results and jack to be at the bottom.
Is that even possible? or even an alternative way where i can achieve the same outcome? Any help would be awesome.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:06 AM
👋 It's not possible to sort results that way. I can't think of a way to achieve this on the server side. But on client side, since you already know the filter condition you can probably sort the results this way.