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 :-
Discussion posts and replies are publicly visible
Hello, below is solution for your problem.
a!localVariables( local!category:{ "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!data:a!forEach( items: local!category, expression: split(fv!item,",") ), local!finalData: a!forEach( items: local!data, expression: a!map( "year":fv!item[1], "category":fv!item[2], "value": fv!item[3] ) ), todatasubset( local!finalData, a!pagingInfo( 1, 10, a!sortInfo( field: "value", ascending: false() ) ) ).data )
And if you want to sort by year then just
change "value" to "year" in the below code.
a!sortInfo( field: "value", ascending: false() )