MongoDB: Sorting by external weights
MongoDB aggregations can be sorted by any field in a document,
but they can also be sorted by external factors.
Say we have some documents with tags:
{'id': 'a', 'tag': 'foo'} {'id': 'b', 'tag': 'bar'} {'id': 'c', 'tag': 'baz'} {'id': 'd', 'tag': 'foo'} {'id': 'e', 'tag': 'bar'} {'id': 'f', 'tag': 'baz'} {'id': 'g', 'tag': 'foo'}