Skip to main content
kavyan471063
Known Participant
Sep 2, 2021 1:49 PM UTC
Question

Sorting months based on chronological order

Hi All,

I am having a list of months shuffled in a list. I want to arrange them in their chronological order. But I can sort only on alphabetical order. Help me guys.

local!months:{"June","January","March","Novemeber","February","October","December","April","July","May","September","August"},
sort(local!months).

Thank you

    16 replies

    mikes0011
    Brainy
    Sep 2, 2021 1:56 PM UTC

    What sort of flexibility do you have?  Can you make your local variable, instead of holding a list of string, hold a list of dictionary/maps instead, in which you give each month a "name" and a "number" parameter?

    The Expression Guru
    gayathris111098
    Inspiring
    Sep 2, 2021 2:00 PM UTC

    a!localVariables(
    local!data_cdt: {
    { monthId: 1, Month: "Jan" },
    { monthId: 2, Month: "Feb" },
    { monthId: 4, Month: "Apr" },
    { monthId: 3, Month: "Mar" }
    },
    todatasubset(
    local!data_cdt,
    a!pagingInfo(
    1,
    - 1,
    a!sortInfo(field: "monthId", ascending: true())
    )
    )
    )

    kavyan471063
    Known Participant
    Sep 2, 2021 2:02 PM UTC

    Thanks for your reply gayatri, Can we sort it without using id values?