Sort the list in order of relationship

For example, I would like to create a relationship where users can “favorite” each other in an N-to-N relationship. (Like in a dating app)
Then, the list of users would be sorted in the order of their “favorites” (i.e., in the order of their relationships).

What do you mean by in order favorites? You should be able to set this up using the database.

Deborah Hearne:
Thank you for your comments.
The order of favorites, in the database, means the order of N-to-N relationships.
For example, there are users named A, B, C, and D.
First, A establishes a relationship with B (A favorites B).
Next, A establishes a relationship with C (A favorites C)
Finally, A establishes a relationship with D (A favorites D)
In this case, I want to sort the users that A has made a relationship with (favorited) by sorting the list.
In order of earliest to latest relationship: B → C → D
Late in the relationship order: D → C → B

RM: Couldn’t yoh just add a date field and sort by the date the relationship was established?

Deborah Hearne:
Thank you very much for your advice.
Currently, I’m afraid I probably can’t do that.
To add to that, in my app, users who form relationships (favorite each other) are in the same collection.

RM: You woukd create a new collection with the relationship. Then you would sort by the date.

Deborah Hearne:
Thank you for your advice.
Is it to create a collection like the following for example?
Property 1: Users with whom you have a relationship
Property 2: Users with whom a relationship has been established
Property 3: Date

RM: That is one way to do it.

Deborah Hearne:
Thank you.
I didn’t tell you, but I actually tried that method.
However, maybe because I have 1000 users in my app, that method makes the list display very slow.
If I don’t create a new collection and just list the users, the display is faster.
So I want a sorting feature that doesn’t create a new collection, but still shows the users in the order in which they are related.

RM: Adelo is having speed issues right now. The only other option is to create a separate date field in the user collection.

Deborah Hearne:
Thank you for your advice.
After adding the date collection to the user collection, how do I set up the sorting of the list?