Sorting an Action List in Power Automate

Options

I am trying to sort the output of an Action List by the Action Solicitor/Fundraiser. The Sort functionality seems simple, but isn't working for me. Any thoughts? It is likely either syntax or placement.

First, I tried to sort the “Append to Array” results near the end of the flow. I don't get an error, but it doesn't sort.

960ff51649af051a1a80a66faba96fb7-huge-im

Then I tried sorting right after the list, but get an error.

e685a2a9702f8d034cbe10758265791a-huge-im
1c972d197813e67fa753c3b88c9710dc-huge-im

Comments

  • @Reuben Schmitz It appears that I neglected to use the Compose Output - is working as it should.

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary Kudos 5 PowerUp Challenge #3 Gift Management Name Dropper

    @Reuben Schmitz
    To use the sort() expression, you can read it here:

    https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#sort

    when you sort without providing the “sortBy” I think it sort based on the first “simple” property it can find, which may not be the sorting you want.

    First point is, you have to use the action that you did the sort on (Compose action), or you can using the array sorted directly in a apply to each loop or create html action. But if you use dynamic content directly from the Action List for Audit variable or List actions action, then the order is still going to the be “old” order before sort.

    Also, you “can't” really sort on the List actions array of actions, as fundraiser is an array of system record id of the fundraiser, unlikely what you want to sort by, nor can sort by as array is not a simple type.

    Then the question becomes, how are you handling action that has multiple fundraiser? From your Append to array variable action, it seems you are using a dynamic content called “Name”, but without seeing what your Apply to each looks like, can't really tell if you are using another apply to each for fundraiser array or only getting “first()” fundraiser.

    Anyway, you don't need a separate Compose action (you can if you want), instead you can do the sort in the create html table action as the array from which you are creating html table for:

    sort(variables('Action List for Audit'), ‘Action Solicitor Name’)

    fd06572d5bd00fcb9c558da7803ccea0-huge-im

Categories