Sort items in a list using Power Automate Desktop

While automating a business process we generally use a lot of lists and sometimes we might need to sort them based on a condition.

Let’s take an example, a bot is processing files present in a folder and it needs to process the file which is created first.

So, the bot needs to sort those files based on creationtime and process them one after the other.

In this article, we will see how to sort items in a list using Power Automate Desktop.

Let’s get into the practical implementation of this task:

Step1: We need to have a list in order to perform sorting. So first, create a list. If you don’t know how to create a list and add items to it refer to the below link:

Now, the list is created and items are added to that list.

Step2: Drag and Drop Sort list action from actions panel to the designer panel as shown below:

sort items in a list

The required properties for this sort list activity are mentioned below:

  • List to sort – Provide the list name that need to be sorted.
  • Sort by list item’s properties – If we are sorting a list of objects that has properties and that list can be sorted based on those properties.(eg: files, folders)

Our input list goes like this {5,9,1,2}

The output of this action is shown below:

sorted list

It always sorts the items in ascending order only.

Now, let’s see the usage of other properties in this action:

In order to complete this example, we are using a list of files because the file properties are used in the sort list action.

If you don’t know how to get the files from a folder follow the below link:

Step3: Drag and Drop sort list action from actions panel to designer panel as shown below and enter the values for mentioned properties:

sort items in a list

Here the input is a list of files.

  • First property to sort by – provide by which property the files need to be sorted. (eg: CreationTime, CreationDate ….)
  • Sort – Provide which order it need to sort.

If you feel you need two more properties while sorting a list then use the remaining two properties that are shown in the above image.

The output for this sort list action using properties is shown below:

sorted in ascending order
sort items in a list

The above-shown images showing the ascending and the descending order of the list of files which is given as input.

Happy Learning!

Like this post then let your friends know about this-:

Leave a Reply

Your email address will not be published. Required fields are marked *