so i am trying to sort notifications array of user by it’s insertion date (i want the latest one on top) but it seems to be not working am i missing something ?
That is, all fields projected out except for notifications. So as you can see, your $sort:{_id:-1} does not make sense because you do not have a field named _id anymore.
If you really want to sort on the top level _id:628ceeae3df06d49419f0bb4, you need to remove _id:0 from your $project.
But, if you want to sort based on the _id within the notifications array and keep the result as an array within each top level document, you will need to use $sortArray.
If you do not want a sorted array within a top level document, you will need an $unwind stage before the $sort stage.
The exact scenario depends on your desired result. If you publish expected resulting documents, the help will be more precise.