Sort the values according category.

Certified Associate Developer

I have a variable that contain list of items, items are ;-

year , category , value

2024, cap internal , 20

2024, cap external, 60

2024, cap material, 50

2025, exp internal , 20

2025, exp external , 30

2025, exp material , 40

I want to sort this like :- 

year , category , value

2024, cap external, 60

2024, cap material, 50

2024, cap internal , 20

2025, exp external , 30

2025, exp material , 40

2025, exp internal , 20

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    a!localVariables(
    local!input: {
    {
    "2024, cap internal , 20",
    "2024, cap external, 60",
    "2024, cap material, 50",
    "2025, exp internal , 20",
    "2025, exp external , 30",
    "2025, exp material , 40"
    }
    },
    local!dictionary: a!forEach(
    local!input,
    a!localVariables(
    local!itemVal: split(fv!item, ","),
    a!map(
    year: local!itemVal[1],
    category: local!itemVal[2],
    value: local!itemVal[3]
    )
    )
    ),
    local!sorted: todatasubset(
    local!dictionary,
    a!pagingInfo(
    1,
    - 1,
    {
    a!sortInfo(field: "year", ascending: true()),
    a!sortInfo(field: "value", ascending: false())
    }
    )
    ).data,
    local!sorted
    )

Reply
  • 0
    Certified Lead Developer

    a!localVariables(
    local!input: {
    {
    "2024, cap internal , 20",
    "2024, cap external, 60",
    "2024, cap material, 50",
    "2025, exp internal , 20",
    "2025, exp external , 30",
    "2025, exp material , 40"
    }
    },
    local!dictionary: a!forEach(
    local!input,
    a!localVariables(
    local!itemVal: split(fv!item, ","),
    a!map(
    year: local!itemVal[1],
    category: local!itemVal[2],
    value: local!itemVal[3]
    )
    )
    ),
    local!sorted: todatasubset(
    local!dictionary,
    a!pagingInfo(
    1,
    - 1,
    {
    a!sortInfo(field: "year", ascending: true()),
    a!sortInfo(field: "value", ascending: false())
    }
    )
    ).data,
    local!sorted
    )

Children