Merge, shuffle, and paginate I'm trying to get a list of users from two different user groups. One user group (premium) must always show first. Whenever the page is loaded, however, the listing of users should show randomly (while keeping premium users at the top of the list).

Also, the listing needs to filter on a particular service which is determined by the entry slug (in the user profiles, that field is set to an Entries fieldtype).

I've been able to get this like so:

{% set thisService = entry.slug %}

{% set premiumMembers = craft.users().group('premium').search('counselingServices:'~thisService) %}
{% set shuffledPremium = shuffle(premiumMembers) %}
{% set basicMembers = craft.users().group('listed').search('counselingServices:'~thisService) %}
{% set shuffledBasic = shuffle(basicMembers) %}

{% set listedMembers = shuffledPremium|merge(shuffledBasic) %}


That all works great, but that of course is an array. I need to paginate the results which isn't possible with an array.

How can I paginate this? Or is there a better way to get the same results in an Element Criteria Model so that I can use the paginate tag?
Got some help and finally got this working. Here's the final code for my future self and anyone else that may need this: 

{% set thisService = entry.slug %}
{% set shufflePremium = shuffle(craft.users.group('premium').search('counselingServices:' ~thisService).ids()) %}
{% set shuffleBasic = shuffle(craft.users.group('listed').search('counselingServices:' ~thisService).ids()) %}
{% paginate craft.users().id(shufflePremium | merge(shuffleBasic)).limit(16).fixedOrder(true) as pageInfo, members %}

{% for user in members %}
  (...)
{% endfor %}