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

Notifications

Announcements

Community site session details

Community site session details

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

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
    13 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,185 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard