Sort results by "is item in array"

I have a data set which includes within each document an array of user IDs that have marked the document as a "preferred" one. I want to be able to sort my documents such that these preferred documents are shown first, before the other documents.

So, how can I sort a set of results by "array contains X", where X is a given user ID? I still want to include all results, but sort the ones containing a matching user ID to the top.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.