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
  • +1
    Certified Lead Developer
    in reply to Mike Schmitt

    Me neither -)

    a!localVariables(
      local!orderedMonthNames: a!forEach(
        enumerate(12),
        text(todate(fv!index & "/1/2021"), "mmmm")
      ),
    
      local!months: {"June", "January", "March", "November", "February", "October", "December", "April", "July", "May", "September", "August"},
    
      reduce(
        a!update(_,_,_),
        {},
        merge(
          a!forEach(
            items: local!months,
            expression: lookup(local!orderedMonthNames, fv!item)
          ),
          local!months
        )
      )
    )

    Have an empty array and insert the strings at the correct index.

Children