web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Sorting (ordering) arrays
Power Automate
Answered

Sorting (ordering) arrays

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi! I'm building an array dynamically in flow and would like to order (sort) the data in the array. How can I acheive it?

Categories:
I have the same question (0)
  • PieterVeenstra Profile Picture
    31 on at

    Hi @PWrobel ,

     

    This is the easiest approach, using an azure function:

     

    https://veenstra.me.uk/2019/07/13/sort-an-array-or-collection-in-microsoft-flow/

  • PWrobel Profile Picture
    Microsoft Employee on at

    Thanks Pieter. To bad there is nothing out of the box that does not require access to Azure subscription.

  • Verified answer
    ilu989 Profile Picture
    164 on at

    Hi @PWrobel ,

     

    I have the same issue but find two websites for me to solve it, it might help you to achieve your requirement:

    http://johnliu.net/blog/2018/12/how-to-implement-sort-with-microsoft-flow-in-3-actions-within-a-loop

     

    The answer from "v-bacao-msft"

    https://powerusers.microsoft.com/t5/Building-Flows/Create-Update-Sharepoint-List-using-an-Excel-List-using-Flow/td-p/297835

     

    Good luck!

    ilu989

  • PWrobel Profile Picture
    Microsoft Employee on at

    Thanks Ilu

     

    I was thinking about building my own sort function in loop, so now I can just copy it 🙂

  • Mx81 Profile Picture
    860 on at

    If you need a build-in function, please vote for this idea:

    https://powerusers.microsoft.com/t5/Power-Automate-Ideas/Sort-Array/idc-p/486807#

  • somefloridaguy Profile Picture
    5 on at

    TRY THIS EXPRESSION (as an Expression for a Compose Action in Flow):

     

    (Assume that "my_array" is the array of POSITIVE INTEGERS that you want to sort.)

     

    Expression (For Ascending Sorting):

    intersection(range(min(my_array),max(my_array)), my_array)
     
    Note: It only works on Positive Integers, but it does NOT require having to create any new Variables or "Apply to each" action loops.
  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    I like the solution by @Paulie78 (https://www.tachytelic.net/2022/07/power-automate-sort-json-array/), it's more universal as it can handle objects and decimal numbers as well.

  • Mx81 Profile Picture
    860 on at

    Finally: there is a sort() expression available.

    And with reverse() you can also do descending sorting.

     

    By the way: I cannot find the ideas section anymore... 😞

    max81_1-1663664175403.png

     

  • Paulie78 Profile Picture
    8,422 Moderator on at

    I did a video on the new expressions:

    How to sort arrays in Power Automate. 

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

    If I answered your question, please accept it as a solution 😘

     

  • JerryFr83560 Profile Picture
    19 on at

    I can't find this.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

Last 30 days Overall leaderboard