get a list of specific values sorted by the sum of specific field that related to the sesific values

i have this schema

const callData = new callDataSchema({
    to        : String,
    userId    : String,
    date      : String,
    direction : String, // if inbound or outband
    duration  : Number,
    from      : String,
});

wich i am using to save a call obj.

as you can see each call obj have a userId field (this field let us know wich user made that call)
and every new call will create a new call obj.

i made a func that returns me some call statistics by user id,

example output :

    {
        "totalDouration": 208,
        "answeredAvg": 12.235294117647058,
        "totalAvg": 3.9245283018867925,
        "allCalls": 53,
        "outbound": 53,
        "inbound": 0,
        "answered": 17,
        "userId": "622dfba7cd94e60667444aad",
    },

the problem is, if i want to use pagination i cant sort the results (because i am using aggrate to get most of the statistics).

i was wonder if there is a way to implement this algoritem with mongodb:

(a) get all unique userIds with distinct

(b) sort userIds by the sum of all of the call duration that belongs to the call objects that contains the same userId

(c) paginate the result (with skip)

example of wanted results:

// for this collection
[
    {
        "to": "a",
        "userId": "1",
        "date": "1647247551021",
        "direction": "outbound",
        "duration": 13,
        "from": "380893202409",
    },
    {
        "to": "b",
        "userId": "1",
        "date": "1647247551021",
        "direction": "outbound",
        "duration": 11,
        "from": "380893202409",
    },
    {
        "to": "c",
        "userId": "2",
        "date": "1647247551021",
        "direction": "outbound",
        "duration": 2,
        "from": "380893202409",
    },
    {
        "to": "d",
        "userId": "2",
        "date": "1647247551021",
        "direction": "outbound",
        "duration": 24,
        "from": "380893202409",
    },
]
// i'll get this list

[
    {
        "userId": "2",
        "total": 26
    },
    {
        "userId": "1",
        "total": 24
    },

thanks.