How to sort multiple field values in particular order?

I have a field called chocolate_type. There are 4 different chocolate types ("Dark", "White", "Milk", "Sweet"). I want my documents to be sorted in a specific order based on the chocolate type. I do not want to sort the chocolate types in ascending or descending order. Instead, I want them to be sorted where white is first, dark second, milk third, and sweet fourth. Here's an example of how the documents should be sorted:

id: 5,

chocolate_type: "White"

id: 8,

chocolate_type: "White"

id: 15,

chocolate_type: "Dark"

id: 18,

chocolate_type: "Dark"

id: 24,

chocolate_type: "Dark"

. . .

How can I make a query that does this?

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