[CMS] Random Sorting / Code help

Hey everyone & @Waldo ! :webflow_heart:

I found this little custom code to enable random sorting which I used to enable random sorting on every reload - which works like a charm!

I was just wondering if it is possible to integrate a field from the CMS item as sorting criteria as well, let me explain:
I’m using the random sort on our Team page to have the team members all shuffled up every time, but I would like to always have a good mix of males & females in it. Especially because we have a bit more males it sometimes happens that the random sorting only shows men for the first 6 cards.
So what I want is that I have a property whether the member is male or female in the CMS and then have a female every 2-3 items so it looks well represented. But I have no idea how to integrate that in the code :grimacing:

I’m very happy if anyone, or you @Waldo :wink: could help me!

Read-only link to my project: Webflow - yamuntu's Website

Would love to know as well.