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
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
-
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 Workplace13 April 2024Power Pages and Cloud Flows – Validate user against Dataverse records based on Contact ID
- Modern Workplace6 April 2024Download SharePoint library files in Power Pages with JavaScript and Cloud flows – Improved code using jQuery & option to open PDF file in a new tab
- Modern Workplace13 March 2024Handle multiple N:N records associate and disassociate requests with JavaScript and Power Pages Web API
- Modern Workplace17 February 2024Generic JavaScript Functions to Associate and Disassociate Dataverse records using the Power Pages Web API