web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Answered

Sort Folder List

(0) ShareShare
ReportReport
Posted on by 205
Hi guys.
How do I correctly set up sorting in the "Sort list" action?
 

What value should I enter so that the list of folders in the "List_FolderNames" variable is sorted in order from smallest to largest: 10, 11, 100, 101, and so on?
 
 
Folder.GetSubfolders Folder: $'''C:\\Users\\1PC\\Desktop\\Folders''' FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.Name SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> Folders
Variables.CreateNewList List=> List_FolderNames
LOOP FOREACH CurrentItem IN Folders
    Variables.AddItemToList Item: CurrentItem List: List_FolderNames
END
Variables.SortList.SortListByProperty List: List_FolderNames Property1: $'''Name''' SortDirection1: Variables.SortDirection.Ascending SortDirection2: Variables.SortDirection.Ascending SortDirection3: Variables.SortDirection.Ascending
 
 
I have the same question (0)
  • Verified answer
    eetuRobo Profile Picture
    4,220 Super User 2025 Season 2 on at
    I think its because the folder names are text. So it checks every character by character so with 100 vs 11 it checks if which first character is higher. Since both have 1 first they are equally high. Then it checks the second character which is 0 in 100 and 1 in 11. 1 is higher so 11 goes before the 100 in the list.

    So you need to convert the text to number. 



    Result:
    Folder.GetSubfolders Folder: $'''C:\\Users\\1PC\\Desktop\\Folders''' FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.Name SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> Folders
    Variables.CreateNewList List=> List_FolderNames
    LOOP FOREACH CurrentItem IN Folders
        Text.ToNumber Text: CurrentItem.Name Number=> TextAsNumber
        Variables.AddItemToList Item: TextAsNumber List: List_FolderNames
    END
    Variables.SortList.SortList List: List_FolderNames
    
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard