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:
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:
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:
More About This Author
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.
- ModernWorkplace2022.11.19Hiding the New and Upload buttons from a SharePoint document library using JSON list formatting
- ModernWorkplace2022.10.25Build powerful Adaptive Card experiences for Teams using Cards for Power Apps
- ModernWorkplace2022.10.15Ignite 2022: Curated list of posts from Microsoft related to Microsoft 365 and Power Platform
- ModernWorkplace2022.10.08Calling Graph API using a flow and manipulating the results from Power Apps using the ParseJSON function