Until recently it was not possible to easily sort arrays or collections of objects in Power Automate using a single expression, either complex logic techniques or Office Scripts were required.
But recently two new handy expressions became available in Power Automate that make it really simple to do:
- sort
- reverse
![](https://i0.wp.com/michelcarlo.com/wp-content/uploads/2022/09/sort.jpg?resize=386%2C224&ssl=1)
How the sort expression work
The sort expression accepts either an array with simple values or a collection of objects.
If you pass a simple array to the expression, no parameter is needed. For example, if you have the following array variable with people’s names:
[
"Michel",
"Nick",
"Michael",
"Carlos",
"Renan"
]
By using the sort expression as below:
sort(variables('Names'))
You will get as output:
[
"Carlos",
"Michael",
"Michel",
"Nick",
"Renan"
]
If you have an array/collection with objects, you need to specify a property to use in the sorting, so for example, consider an array variable named ‘NamesCountries’ as below:
Source link
More About This Author
![michelcarlo](https://i0.wp.com/365community.online/wp-content/uploads/2020/04/C6zQCIg6_400x400.jpg?resize=150%2C150&ssl=1)
-
SharePoint and Office 365 Consultant/Developer always trying to get the best from Microsoft stack (Microsoft 365/Azure/Power Platform and related stuff).
Living in Ireland since 2018, I had previously worked in Brazil as a consultant/developer for Office 365, SharePoint and related technologies for almost 10 years.
Array
Modern Workplace24 July 2024Power Pages Table Permissions: Configure permissions to see records from child Accounts
Modern Workplace15 July 2024Copy Dataverse contact phone numbers across different environments based on Contact e-mail address using Power Automate
Modern Workplace1 June 2024Get the current logged Power Pages user Contact ID via JavaScript and use it to create records assigned to the current user
Modern Workplace11 May 2024How to get the current Azure Devops iteration name for a project using Power Automate