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

Announcements

News and Announcements icon
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,524 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 785

#2
Valantis Profile Picture

Valantis 669

#3
Haque Profile Picture

Haque 563

Last 30 days Overall leaderboard