Okay. That is a long title.
This is a follow-up to my previous post: Populate Power Apps drop down box with Office 365 group.
If you care about the order of the contents of your drop down list then this post is for you.
Previously, I added Office 365 groups as a data source, added a drop down box to my app, modified the app’s OnStart property to create a collection from my Office 365 group, and populated the drop down box with the values in the collection. Now, I will sort the list so that the names appear in alphabetical order.
To accomplish this, I modify the app’s OnStart property to create another collection. Here is the code that I already had in the OnStart property:
Check out my previous post for an explanation of what this does and how to modify it.
Create a new collection from a previous collection and sort it
Now I create a new collection by appending this code to the end of the previous code in the app’s OnStart property:
Note: Make sure you add a semi-colon to the end of the original code before you append the new code or you will have errors. Also, be sure to replace the names of my collections, mySortedCollection and myCollection to the names of your collections.
Run OnStart as shown in the previous post and view the collection.
Update the Items property for your drop down
Make sure that the Items property for your drop down is the new sorted collection by selecting your drop down and in the Properties pane select the new collection. Play the app and view the drop down values.
That’s it! Enjoy your sorted list.