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 / Sort JSON array by key
Power Automate
Answered

Sort JSON array by key

(1) ShareShare
ReportReport
Posted on by 6

Hi there,

 

I am using the action "Parse JSON" in my Flow and would like to sort the results by a specific key.

 

So, in the following example I want to sort elements by "SubscriptionName". Can anyone help me to find the correct answer and tell me where to insert by sort function into the following code?

 

Thx in advance

Dorothee

 

{
    "type""array",
    "items": {
        "type""object",
        "properties": {
            "Charge DateDif": {
                "type""integer"
            },
            "ChargeEndDate": {
                "type""string"
            },
            "ChargeStartDate": {
                "type""string"
            },
            "CustomerID": {
                "type""string"
            },
            "Id": {
                "type""string"
            },
            "IdRechnungsnummer": {
                "type""string"
            },
            "MailSent": {
                "type""string"
            },
            "Quantity": {
                "type""integer"
            },
            "Source.Name": {
                "type""string"
            },
            "SubscriptionName": {
                "type""string"
            },
            "VK": {
                "type""number"
            },
            "Auftragsnummer": {
                "type""string"
            },
            "CustomerName": {
                "type""string"
            }
        },
        "required": [
            "Auftragsnummer",
            "Charge DateDif",
            "ChargeEndDate",
            "ChargeStartDate",
            "CustomerID",
            "CustomerName",
            "Id",
            "IdRechnungsnummer",
            "MailSent",
            "Quantity",
            "Source.Name",
            "SubscriptionName",
            "VK"
        ]
    }
}
Categories:
I have the same question (0)
  • Verified answer
    v-litu-msft Profile Picture
    Microsoft Employee on at

    Hi @Dorothee123,

     

    It's unfortunate insert in order function into the schema is not supported on Power Automate yet.

    As a workaround, there is a blog that sorts an array by building an expression:

    https://sharepains.com/2019/07/13/sort-an-array-or-collection-in-microsoft-flow/

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Dorothee123 Profile Picture
    6 on at

    Thanks @v-litu-msft for your quick reply

  • Jnas Profile Picture
    30 on at

    By now there is a way to sort JSON arrays by a key: Just add a new compose action and use the sort() function.

    To sort by the key "SubscriptionName", one would use the following code:

    sort(body('NameOfPreviousJSONAction'),'SubscriptionName').

    Just replace NameOfPrevoiusJSONAction with your preceding JSON action. The default order of the sort() function seems to be ascending.

    Below is an example from a flow of mine. I sorted my JSON array by the key "KST".

    Jnas_0-1716395854141.png

     

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard