I have user document collection like this:
User {
id:\"001\"
name:\"John\",
age:30,
friends:[\"userId1\",\"userId2\",\"userId3\"....]
}
>
Edit: this answer only applies to versions of MongoDb prior to v3.2.
You can't do what you want in just one query. You would have to first retrieve the list of friend user ids, then pass those ids to the second query to retrieve the documents and sort them by age.
var user = db.user.findOne({"id" : "001"}, {"friends": 1})
db.user.find( {"id" : {$in : user.friends }}).sort("age" : 1);