When you start working with data in PowerApps, one of the first things you’ll need is sorting. Maybe you want to show the highest salary first, or arrange names alphabetically. For that, PowerApps gives you two options: Sort() and SortByColumns().
At first, they look almost the same. But once you use them, you’ll notice they behave a bit differently. Let’s understand this in a simple way.
Example Setup (Using Collection)
Before jumping into functions, let’s create a simple collection so you can test everything yourself.
ClearCollect(
colEmployees,
{
Name: "Amit Shah",
Department: "IT",
Salary: 50000,
Bonus: 5000
},
{
Name: "Neha Patel",
Department: "HR",
Salary: 40000,
Bonus: 8000
},
{
Name: "Ravi Kumar",
Department: "IT",
Salary: 60000,
Bonus: 2000
},
{
Name: "Priya Mehta",
Department: "HR",
Salary: 45000,
Bonus: 3000
}
)
Set your Gallery Items property to
colEmployees
What is Sort() function?
Think of Sort() as the more flexible option.
You can use it when you don’t just want to sort by a column, but maybe by some calculation or logic.
Example:
Sort(colEmployees, Salary, SortOrder.Descending)
![05-05-2026-11-31-13]()
This simply sorts employees by salary.
Now here’s where it becomes useful:
Sort(colEmployees, Salary + Bonus, SortOrder.Descending)
![05-05-2026-11-32-37]()
Now you’re sorting based on total earnings (salary + bonus), not just one column.
So basically, Sort is useful when your sorting is not straightforward.
What is SortByColumns() function?
SortByColumns() is more direct and simple.
You just tell it which column to sort, and it does the job.
Example
SortByColumns(colEmployees, "Salary", SortOrder.Descending)
![05-05-2026-11-34-27]()
This does the same thing as the first Sort example.
But here’s the advantage:
SortByColumns(colEmployees, "Department", SortOrder.Ascending, "Salary", SortOrder.Descending)
![05-05-2026-11-35-55]()
Now it first sorts by Department, and then within that, by Salary.
This is something Sort cannot do easily.
So what’s the real difference?
Here’s the easiest way to think about it:
Final Thoughts
Both functions do the same basic job—sorting data. The difference is in how you want to control that sorting.
If your requirement is simple, go with SortByColumns().
If your requirement is a bit tricky or involves calculations, go with Sort().
That’s it. No need to overcomplicate it.