Skip to main content

How to Sort a Table in Power Apps with Sort

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Sort puts the rows of a table in order: people by name, requests by date, items by priority. Data from connectors comes back in whatever order the service chooses, so sorting it yourself makes lists predictable. Here's the syntax, the descending option, and a real example.

Syntax​

Syntax
Sort( Table, Formula [, SortOrder ] )
  • Formula is worked out for each row, usually just a column name, and the rows are ordered by the result. It must give a number, text or true/false.
  • SortOrder is SortOrder.Ascending (the default) or SortOrder.Descending.

Sort returns a new table and doesn't change the original (Sort reference).

Prerequisites​

Step 1: The Order You Get Without Sort​

For Daniel, a manager in the example's demo organization, the connector returned Aisha Khan, Leo Martin. That happens to be alphabetical, but nothing guarantees it.

Step 2: Sort Descending​

To see Sort change something, sort by name the other way:

Text control → Text
Concat(
Sort(Office365Users.DirectReportsV2("daniel.brooks@example.com").value, displayName, SortOrder.Descending),
displayName,
", "
)

The formula bar with Sort of Daniel's direct reports by displayName with SortOrder.Descending inside Concat, the preview strip reading Leo Martin, Aisha Khan with Data type text

Concat just shows the result as one line of text; see How to Join Table Values into Text in Power Apps with Concat.

Step 3: Sort What You Filtered​

The Career Development Plan app keeps a manager's team in name order, after removing disabled accounts:

App → Formulas
MyDirectReports = Sort(
Filter(
Office365Users.DirectReportsV2(
MyProfile.id,
{'$select': "id,displayName,mail,userPrincipalName,jobTitle,accountEnabled"}
).value,
accountEnabled
),
displayName
);

No SortOrder means ascending: A to Z. See How to Filter a Table in Power Apps with Filter.

Sorting by More Than One Column​

Nest Sort, innermost first:

Example
Sort( Sort( Contacts, FirstName ), LastName )

or use SortByColumns with column names as text: SortByColumns(Contacts, "LastName", SortOrder.Ascending, "FirstName", SortOrder.Ascending).

Common Mistakes​

MistakeWhat happensDo this instead
Relying on a connector's orderIt can changeSort explicitly
Sorting by a field you didn't '$select'Every value is blank, so nothing is orderedAdd the field to '$select'
Sorting a big SharePoint list by a choice or lookup columnIt may not be delegable, so results can be incompleteSort by a plain column, or sort a smaller filtered set

Troubleshooting​

SymptomLikely causeFix
The order didn't changeAlready in that orderTry SortOrder.Descending to check
A delegation warningThe data source can't sort by that columnSort by a delegable column

FAQ​

Is ascending A to Z?​

Yes, for text. For numbers, smallest first; for dates, earliest first.

Does Sort change the data source?​

No. It returns a sorted copy for your formula or gallery.

Sort or SortByColumns?​

Sort can sort by any formula, such as Quantity + OnOrder. SortByColumns sorts by named columns and can take an explicit order list.

Conclusion​

Sort(table, column) orders rows A to Z; add SortOrder.Descending for Z to A. Sort connector results explicitly, and combine Sort with Filter for lists that are both relevant and tidy.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.