Hello All,
I have constant with holds distinct values of usernames.
The constant USER_GROUP has the values {gamma, beta, alpha}
Earlier we had a sort() function which would sort the data for us, but this function is no longer available.
In documentation I see only a!sortInfo available which is useful to sort the data from DB and I cannot use any utilities as well for sorting the data.
So can anyone suggest an alternate way to sort the data in a constant to {alpha, beta, gamma}
a!localVariables( local!sendingName: getdistinctusers(cons!USER_GROUPS) local!sendingName )
Thanks & Regards
Girish Katti
Discussion posts and replies are publicly visible
Hi,
This is one possible way for sorting:
todatasubset( a!forEach( items: { "gamma", "beta", "alpha" }, expression: { value: fv!item } ), a!pagingInfo( startIndex: 1, batchSize: - 1, sort: a!sortInfo(field: "value", ascending: true()) ) ).data.value
The function sort() was always private API and undocumented. The only way I am aware of, is to turn the list into a list of dictionaries and then use todatasubset() for sorting.
Code similar to this should create the list of dictionary.
a!foreach( items: getdistinctusers(cons!USER_GROUPS), expression: a!map(user: fv!item) )
Thankyou very much for sharing the information.
This is also one of those utility rules that I often create / import before any project and reuse!