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
  • Turns out I can't resist a fun challenge...

    a!localVariables(
      local!orderedMonthNames: a!forEach(
        enumerate(12),
        text(todate(fv!index & "/1/2021"), "mmmm")
      ),
      
      local!months: {"June", "January", "March", "Novemeber", "February", "October", "December", "April", "July", "May", "September", "August"},
      
      local!mapped: a!forEach(
        local!months,
        a!map(
          name: fv!item,
          number: index(wherecontains(fv!item, local!orderedMonthNames), 1, -1)
        )
      ),
      
      todatasubset(
        arrayToPage: local!mapped,
        pagingConfiguration: a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: "number",
            ascending: true()
          )
        )
      ).data
      
    )

Children