Sorting months based on chronological order

Certified Senior Developer

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

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to kavyanatrajan

    may be you can alter like this

    a!localVariables(
    local!months: { "Jan", "Feb", "Apr", "Mar" },/*input*/
    local!months_txt: { "Jan", "Feb", "Mar", "Apr" },
    /*Constant*/
    local!monthIds_int: { 1, 2, 3, 4 },
    /*Constant*/
    local!data_cdt: a!forEach(
    items: local!months,
    expression: a!map(
    monthId: displayvalue(
    fv!item,
    local!months_txt,
    local!monthIds_int,
    ""
    ),
    monthName: fv!item
    )
    ),
    todatasubset(
    local!data_cdt,
    a!pagingInfo(
    1,
    - 1,
    a!sortInfo(field: "monthId", ascending: true())
    )
    ).data.monthName
    )