For the sake of the example lets say I have 15 users:
- membertype_id = 2 (5 users called a,b,c,d,e)
- membertype_id = 3 (5 users called f,g,h,i,j)
- membertype_id = 4 (5 users called k,l,m,n,o)
I normally sort them with User.order("membertype_id DESC") to make them go:
a,b,c,d,e - f,g,h,i,j - k,l,m,n,o
Now I want to shuffle inside the 3 different categories, but still keep the overall order from the membertype_id:
For instance it could return it in this order:
d,c,a,b,e - g,f,i,j,h - k,m,n,l,o
or
a,c,e,b,d - f,i,j,h,g - m,k,n,o,l
or
b,d,c,a,e - j,g,h,i,f - k,n,o,l,m
but never
m,j,k,a,f,e,b,g,d,h,i,o, and so on
How would I accomplish this? I need to return an ActiveRecord_Relation.