I have a transaction item (dictionary) with keys of, say…Name, Age, and City.
While processing the item, I add keys with Date and Result. Then I want to include Name, Age, City, Date, and Result in a confirmation email - but I want Date and Result first, not last.
Is there a way to change the order of the keys within a dictionary? Or if there’s a way to have it add a new key at the beginning instead of the end, that would work too.
That’s an interesting thing, but I don’t know if it helps me here because the dictionary is actually transactionItem.SpecificContent which is automatically created by the Get Transaction activity. I don’t think I can control the datatype of SpecificContent.
I suppose I could create a transactionDict as an OrderedDictionary, and copy SpecificContent to it then work with transactionDict in the rest of my automation. Might be a reasonable solution if nothing better is available.
(From kvp In dictDemo
Order By Array.IndexOf(arrOrder, kvp.Key) Descending).ToDictionary(Function (x) x.Key,Function (x) x.Value)
Result:
Kindly note: as we do reverse the order to handle -1 from indexof for not specified keys in the sort order the first element has to be the last item within the sort definition array