Do you know how to sort a collection alphabetically in Power Apps? No worries!
In this Power Apps tutorial, I will explain how to Sort Power Apps Collection alphabetically, including many more like:
- How to sort Power Apps collection by ascending
- Power Apps sort collection by descending
- How to sort Power Apps collection by ascending and descending
- Working with the Power Apps sort collection by multiple columns
How to Sort Power Apps Collection Alphabetically
Here, we will discuss how to sort a Power Apps collection alphabetically [Ascending].
Example:
1. I manually created a Power Apps collection, i.e., [colEventRegistration]. This collection contains the below Headers/Columns with respective records.
- Name
- Company Name
- Gender
- Age
Refer to the below image:

2. In Power Apps, there is a Data table control. This data table will sort and display each record from the Power Apps collection based on the “Name” column in ascending order.

To achieve the above example, follow the below-mentioned steps. Such as:
3. To create a Power Apps Collection, go to App’s OnStart property and write the code below:
OnStart = ClearCollect(
colEventRegistration,
{
Name: "John Smith",
CompanyName: "Buckeyee Furniture",
Occupation: "Training and development specialist",
Age: 34,
Gender: "Female"
},
{
Name: "Emma Reyna",
CompanyName: "Fox valley CPAs",
Occupation: "Accountant",
Age: 32,
Gender: "Female"
},
{
Name: "Kelven",
CompanyName: "Bugle Boy",
Occupation: "Daimond Tracker",
Age: 44,
Gender: "Male"
},
{
Name: "Lynee",
CompanyName: "Specific Appraisals",
Occupation: "Computer and Information Researcher",
Age: 40,
Gender: "Male",
PhoneNumber: 5360875
},
{
Name: "Steve Mroz",
CompanyName: "Maxigraphics",
Occupation: "Graphic Designer",
Age: 39,
Gender: "Male",
},
{
Name: "Henrita Mullar",
CompanyName: "Happy Harry's",
Occupation: "Customer Suppot Executive",
Age: 36,
Gender: "Female"
}
)
Where,
- colEventRegistration = Power Apps Collection Name
- Name, CompanyName, Occupation, Age, Gender = Collection Headers/Columns
- “John Smith”, “Buckeyee Furniture”, “Training and development specialist” = Collection Records/Rows

4. Insert a Data table control and set its Items property to the code below.
Items = Sort(
colEventRegistration,
Name
)
Where,
- Sort() = Power Apps Sort() function helps us to sort the table depending on the formula
- colEventRegistration = Power Apps Collection Name
- Name = Collection Column Field

5. Click on the Run OnStart under the App object like below.

6. Save, Publish, and Preview the app. The data table displays the sorted records [Event Registration Records] based on the based on “Name” column in ascending order as in the screenshot below.

This is how to sort a Power Apps collection by ascending order.
Power Apps Sort Collection By Descending [Z-A]
Next, I will show you how to sort a Power Apps collection in descending order.
Example:
- I will also take the same Power Apps collection [colEventRegistration] for this example.
- In Power Apps, there is a Data table control. This data table will sort and display each record from the Power Apps collection based on the “Name” column in descending order.

To work around this example, follow the below steps:
3. On the Power Apps Screen -> Insert a Data table and set its Items property as:
Items = SortByColumns(
colEventRegistration,
"Name",
SortOrder.Descending
)
Where,
- SortByColumns() = This function is also used to sort the table depending on the formula
- “Name” = Power Apps Collection Column Field
- SortOrder.Descending = Descending order of the Power Apps collection based on the “Name” column

4. Run OnStart, Save, Publish, and Preview the app. The data table displays the sorted records [Event Registration Records] based on the based on “Name” column in descending order like below.

This is how we can sort a Power Apps collection by descending order.
Power Apps Sort Collection By Ascending And Descending
Let’s discuss sorting a Power Apps collection by ascending and descending order.
Example 1:
1. I have a SharePoint Online List named “Vacation Budget“. This list contains the below fields.
Column Name | Data Type |
Destination | It is a default single line of a text column, I just renamed it as “Destination” |
Expense Type | A single line of text |
Category | Choice |
Unit Price | Currency |

2. In Power Apps, there is a Sort icon and a Data table. Whenever a user can sort the records either in ascending or descending order based on the only title column [Destination], the data table will display the sorted records.

To do so, follow the below steps.
3. On the Power Apps Canvas app -> Select the App object and set its OnStart property as:
OnStart = ClearCollect(
colVacations,
'Vacation Budget'
)
Where,
- colVacations = Power Apps Collection
- ‘Vacation Budget’ = SharePoint Online List

4. Insert a Sort icon and set its OnSelect property as:
OnSelect = Set(
varColumn,
"Title"
);
Set(
varOrder,
If(
varOrder = SortOrder.Ascending,
SortOrder.Descending,
SortOrder.Ascending
)
)
Where,
- Set() = This Power Apps Set() function helps us to set a global variable
- varColumn = 1st Global Variable Name
- “Title” = SharePoint Title Field
- varOrder = 2nd Global Variable Name
- SortOrder.Descending, SortOrder.Ascending = Sort order can be either ascending or descending

5. Then, insert a Data table control and set its Items property to the code below.
Items = SortByColumns(
colVacations,
varColumn,
varOrder
)
Where,
- colVacations = Power Apps Collection
- varColumn, varOrder = Power Apps Global Variables

6. Click on the Run OnStart under the App object like below.

7. Save, Publish, and Preview the app. The Data table displays sorted records based on the selecting sort icon [Either ascending or descending] as shown below.

Example 2:
- I will also take the same SharePoint Online list [Vacation Budget] for this example.
- In Power Apps, there are two button controls and a Data table.
- Sort By A-Z: Whenever the user can sort the record based on the ascending order of the Title [Destination] column, the data table will display the records in ascending order.
- Sort By Z-A: Whenever the user can sort the record based on the descending order of the Title [Destination] column, the data table will display the records in descending order.
Refer to the below screenshot:

To do so, follow the below steps.
3. On the Power Apps Screen, insert two Button controls and set its OnSelect property codes as:
OnSelect = Set(
galsort,
"AZ" // For Ascending Order
)
OnSelect = Set(
galsort,
"ZA" // For Descending Order
)
Where,
- galsort = Power Apps Global Variable
- “AZ”, “ZA” = Variable Values

4. Then, insert a Data table and set its Items property as:
Items = If(
galsort = "AZ",
Sort(
colVacations,
Title,
SortOrder.Ascending
),
galsort = "ZA",
Sort(
colVacations,
Title,
SortOrder.Descending
)
)
Where,
- If() = This Power Apps If() function evaluate the unrelated conditions
- galsort = Power Apps Global Variable
- colVacations = Power Apps Collection
- Title = SharePoint Title Field

5. Run Onstart, Save, Publish, and Preview the app. The data table displays sorted records based on the selected button [Sort By A-Z and Sort By Z-A] controls as in the screenshot below.

This is all about the Power Apps sort collection by ascending and descending.
Power Apps Sort Collection By Multiple Columns
Last, we will learn how to sort a Power Apps collection by multiple columns.
Example:
- I will also take the same SharePoint Online list [Vacation Budget] for this example.
- In Power Apps, there is a Data table. This data table will sort and display each record from the SharePoint Online list based on the two text columns, i.e., [Destination and ExpenseType].
Refer to the below screenshot:

To work around this example, follow the below steps.
3. On the Power Apps Screen -> Insert a Data table and set its Items property as:
Items = SortByColumns(
colVacations,
"Title",
SortOrder.Descending,
"ExpenseType",
SortOrder.Ascending
)
Where,
- “Title”, “ExpenseType” = SharePoint List Text Fields

4. Run Onstart, Save, Publish, and Preview the app. The data table displays sorted records based on the two text columns, as in the screenshot below.

This is how to sort a Power Apps collection by multiple columns.
Conclusion
I hope you have a complete idea of how to alphabetically sort the Power Apps collection.
Here, I explained how to sort a Power Apps collection by ascending and how to sort a Power Apps collection by descending.
Also, we discussed the Power Apps sort collection by ascending and descending and how to sort a Power Apps collection by multiple columns.
Also, you may like some more Power Apps tutorials:
- Bind Dropdown Items from Power Apps Collection
- Create Power Apps Collection from Multiple SharePoint Lists
- Power Apps Collection GroupBy
- Filter Power Apps Gallery By Multiple Dropdowns
- Bind Power Apps Dropdown Items From Collection
Bijay Kumar Sahoo is a highly accomplished professional with over 15 years of experience in the field of SharePoint and related technologies. He has been recognized as a Microsoft MVP (Most Valuable Professional) more than 9 times, starting from April 2014, for his exceptional contributions to the SharePoint community. Bijay is also a prolific author, having written two books on SharePoint – “Microsoft Power Platform – A Deep Dive” and “SharePoint Online Modern Experience Practical Guide“. His deep insights into SharePoint are also shared on his popular YouTube channel EnjoySharePoint where he teaches SharePoint to a global audience (From various countries like the United States of America, Canada, the United Kingdom, Australia, New Zealand, etc). Read more…