'Sort DD/MM date on a .find() with Mongoose

I was trying to find how can I sort birthdays date by day and months with a .find() performed by mongoose.
Actual code:

const embed2 = new MessageEmbed()
.setColor('#FBC78E')
.setTitle(`Liste des anniversaires de ${message.guild.name}`)
birthday.find({}).then(data => {
  embed2
  .setDescription(Array.from(data).map(u => `<@${u.user_id}> : ${u.birthday}`))

  loading_message.delete();
  message.guild.channels.resolve(args[1]).send(embed2)
});

The problem is that when I try to do add a .sort('birthday') to my .find(), it only filters the days, but it's not what I'm searching for, here's the result of the .find() (without the .sort()):

[
  {
    _id: new ObjectId("620d763c86159915746f431b"),
    user_id: '493470054415859713',
    birthday: '04/11',
    __v: 0
  },
  {
    _id: new ObjectId("620d770505fa9fe0910968c0"),
    user_id: '933751655046979645',
    birthday: '18/05',
    __v: 0
  },
  {
    _id: new ObjectId("620d77575417ab94a5f2c837"),
    user_id: '735987183714041867',
    birthday: '15/12',
    __v: 0
  },
  {
    _id: new ObjectId("620d85fed17e202ed6d2b847"),
    user_id: '320851795058360331',
    birthday: '03/11',
    __v: 0
  }
]

Excepted result:

[
  {
    _id: new ObjectId("620d770505fa9fe0910968c0"),
    user_id: '933751655046979645',
    birthday: '18/05',
    __v: 0
  },
  {
    _id: new ObjectId("620d85fed17e202ed6d2b847"),
    user_id: '320851795058360331',
    birthday: '03/11',
    __v: 0
  },
  {
    _id: new ObjectId("620d763c86159915746f431b"),
    user_id: '493470054415859713',
    birthday: '04/11',
    __v: 0
  },
  {
    _id: new ObjectId("620d77575417ab94a5f2c837"),
    user_id: '735987183714041867',
    birthday: '15/12',
    __v: 0
  }
]

As you can see here, the birthdays are sorted by day AND month, which is what I try to do. Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source