Do you want to know how to use the sort function in Power Apps? Here, I will explain with examples of the PowerApps sort function and the Power Apps sort by column.
I will explain the syntax of the Power Apps sort() function and the syntax of the Power Apps SortByColumns() function.
Power Apps Sort() Function
Power Apps Sort function helps to sort the table depending on the formula the user provides. The formula output must be an integer, a Boolean, or a string value. The output cannot be in a table or record.
Syntax:
Below represents the syntax of the Power Apps Sort Function:
Sort( Table, Formula [, SortOrder ] )
Where,
- Table = This is required. Specify the table name that you want to sort.
- Formula = This is also required where the formula helps to execute each and every record of the table. The outputs are used to sort the table.
- SortOrder = This is optional. You need to provide an order format like SortOrder.Descending to sort the table in descending order where the SortOrder.Ascending helps to sort the table in ascending order. SortOrder.Ascending is the default value.
Sort function Power Apps example
Now, we will see various Sort Function Power Apps Examples. Follow the instructions below:
Set up a SharePoint List
The below image represents a SharePoint list named Employee Onboarding. This list has these many columns below:
Columns | Datatypes |
---|---|
Employee ID | Number |
Employee Name | By default, this is a Title column. I just renamed it to Employee Name |
Employee Last Name | Single line of text |
Department | Choice |
Location | Choice |
Picture | Image |
Refer to the screenshot below.

Create a Power Apps Collection from the SharePoint List
1. Next, we will create a Power Apps Collection from this SharePoint list [Employee Onboarding] in the Power Apps canvas app.
2. To do so, go to App’s OnStart property and apply the code below:
OnStart = ClearCollect(
colEmpOnboarding,
'Employee Onboarding'
)
Where,
colEmpOnboarding = Collection Name

3. Run the App’s OnStart property. Now, the collection will be created from the SharePoint list.
4. To display the collection data, go to Variables (x) -> Expand Collections -> Click on ellipses (…) of the created collection -> Select View Table. Then, all the collection records will be visible, as shown below. Click on Cancel.

Example – 1:
In this example, we will sort the Power Apps gallery by Employee Name (from the collection).
To achieve this, insert a Vertical gallery control and set its Items property to the code below:
Items = Sort(
colEmpOnboarding,
Title
)
Where,
Title = Provide the column name that you want to sort
Then, all the gallery records will be displayed alphabetically based on the Title/Employee Name.

This is how to sort the power apps gallery.
Example – 2:
In this example, we will see how to work with PowerApps sort alphabetically.
Suppose you want to arrange the gallery data based on ascending or descending order. In that case, you must use the Power Apps SortOrder () function.
NOTE:
The formula will take ascending order by default if you do not specify the Power Apps sort order.
To work around this, select the gallery control and set its Items property to the code below:
Items = Sort(
colEmpOnboarding,
Title,
SortOrder.Descending
)
Where,
SortOrder.Descending = I wanted to display the gallery items based on descending order, so I mentioned SortOrder.Descending. To display in ascending order, you can provide the code as SortOrder.Ascending.
Then, all the gallery records will be displayed in descending order based on the Title/Employee Name.

This is how to use the sort function in powerapps.
Power Apps sortbycolumns()
- Power Apps SortByColumns is a function that helps sort the table based on multiple fields or columns. The names of the columns to be sorted and the sort direction for each column are provided in the parameter list for SortByColumns.
- The parameters are sorted in the following order: first by the first column, then by the second, and so on.
- Column names are given as strings and must be included in double quotes if they are to be included in the parameter list. For example, SortByColumns(EmployeeTable, “LastName”).
- Users can choose which column to sort by combining SortByColumns with a Dropdown or List box control.
Syntax of Power Apps sortbycolumns()
Below are the syntaxes of the Power Apps SortByColumns Function:
Syntax – 1:
SortByColumns( Table, ColumnName1 [, SortOrder1, ColumnName2, SortOrder2, ... ] )
Where,
- Table = This is required. Specify the table name that you want to sort.
- ColumnName(s) = This is also required. Provide the column names that you want to sort, as strings.
- SortOrder(s) = This is optional. You need to specify the order as SortOrder.Ascending or SortOrder.Descending. And, SortOrder.Ascending is the default value. If multiple ColumnNames are supplied, all but the last column must include a SortOrder.
Syntax – 2:
SortByColumns( Table, ColumnName, SortOrderTable )
Where,
- Table = This is required. Specify the table name that you want to sort.
- ColumnName = This is also required. Provide the column name that you want to sort, as strings.
- SortOrderTable = This is also a required parameter. Specify the single-column table of values to sort by.
Sort by columns Power Apps Examples
This section will show how to work with sortbycolumns() in powerapps.
In the screen below, three records in the gallery are displayed at the top, and the remaining are displayed from the collection as it is.
That means you can sort and display your desired data first, then the remaining.

To do so, select the Gallery control and set its Items property to the code below:
Items = SortByColumns(
colEmpOnboarding,
"Title",
[
"Wego",
"Diego"
]
)
Where,
- “Title” = Provide the column name that you want to sort
- [“Wego”, “Diego”] = Specify the names you want to sort at the top of the gallery
Refer to the image below.

This is how to work with Power Apps sort by columns.
Conclusion
I hope now you have an idea of how to use the sort() function in Power Apps and also the Power Apps sortbycolumns() function.
I have taken here two examples of sort function in PowerApps and Power Apps sort by column.
You may like the following tutorials:
- Sort Power Apps Gallery By ID
- Power Apps Sort Distinct Filter
- Power Apps Filter Gallery By Quarter
- Power Apps Filter Gallery By Year
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com