Change order of keys in dictionary?

@postwick

  • in general it is more about the access order when the dictionary is used for the email.
  • we can use the prepend method for adding an item on the first position

However with following approach it can be reordered and will not loose items which are not defined in the order definition:

Variable:
grafik

input:

flow:
grafik

(From kvp In dictDemo
Order By Array.IndexOf(arrOrder, kvp.Key) Descending).ToDictionary(Function (x) x.Key,Function (x) x.Value)

Result:
grafik

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

1 Like