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 / Internal error returne...
Power Automate
Answered

Internal error returned when trying to sort an array of objects

(0) ShareShare
ReportReport
Posted on by 8

I get an internal error when I try and sort an array of objects.  Any ideas are welcome?

 

Jivin_1-1664786003633.png

Jivin_2-1664786033609.png

 

Categories:
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Jivin ,

     

    You missed the second parameter.

    vxiaochenmsft_0-1664786894460.png

     

    Best Regards,

    Wearsky

  • Expiscornovus Profile Picture
    33,997 Most Valuable Professional on at

    Hi @Jivin,

     

    The Array would have the items in the body. And since you have two properties I would suggest to specify on which field you want to sort.


    Can you try this instead?

    sort(body('Array'), 'last')
  • Jivin Profile Picture
    8 on at

    Worth a shot but the array doesn't have body:  

    Jivin_1-1664791399550.png

    I tried your suggestion anyway:

    Jivin_2-1664791549167.png

     

    Jivin_0-1664791363055.png

     

    But your and @v-xiaochen-msft's suggestion of specifying the field to sort on does the trick.

     

    Jivin_3-1664791685416.png

     

     

    Jivin_4-1664793546707.png

    My reading of the doco is that the second parameter in the sort function is optional.  Maybe not when sorting an array of objects?

     

    Thanks for your ideas.

     

    Jivin

     

     

    Jivin_5-1664793617269.png

     

  • Expiscornovus Profile Picture
    33,997 Most Valuable Professional on at

    Hi @Jivin,

     

    Out of interest, what kind of array did you use that you don't have a body? Is it just a Compose action?

  • Jivin Profile Picture
    8 on at

    Hi @Expiscornovus 

     

    Correct, I just used a Compose action.  

     

    I've now applied what I learnt to my real problem and got that working.  

     

    A couple of other sort related things:

     

    I also discovered that the sort function doesn't like nested objects so I had to use a Select action before calling sort to make sure my data was better organised. 

     

    When using sort you also have to be careful that none of the values you are sorting on are null.

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 424

#2
11manish Profile Picture

11manish 328 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard