Skip to main content
kavyan471063
Known Participant
September 2, 2021
Question

Sorting months based on chronological order

  • September 2, 2021
  • 16 replies
  • 0 views

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
    September 2, 2021

    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?

    gayathris111098
    September 2, 2021

    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
    September 2, 2021

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