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 Platform Community / Forums / Power Automate / How to Sort PDF Files ...
Power Automate
Suggested Answer

How to Sort PDF Files Alphabetically (Descending) Before Displaying in Dropdown via Adaptive Card?

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

I'm currently working on a Power Automate flow that reads PDF files from a SharePoint folder and displays them in a dropdown menu within an Adaptive Card in a Power Virtual Agent.

The flow works and the files are listed correctly – however, I’d like to sort the filenames alphabetically in ascending order before showing them in the dropdown. So far, my approach looks like this:

  1. List folder (using "Get files")

  2. Filter array – Only keep items where Name ends with .pdf

  3. Build array – Map each item with title = Name, value = Name

  4. Compose – Assemble the JSON string for the Adaptive Card dropdown

Is there a simple way to sort the array of PDF filenames in ascending (A to Z)?

Any tips on how to best integrate the sorting step into this flow would be greatly appreciated!

Thanks in advance
 

Categories:
I have the same question (0)
  • Suggested answer
    Ellis Karim Profile Picture
    11,691 Super User 2025 Season 2 on at
    Hi 
     
    You can use the following parameters to sort the output of the Get Files action by filename, in ascending order:
     
     
    Filter Query
    substringof('.pdf', FileLeafRef) and FSObjType eq 0
    
    Order By
    FileLeafRef asc
    • In the filter query we need to use the Document Library’s internal name FileLeafRef - which gives us the name of the file including its extension.
       
    • The substringof function return all items where the file name (FileLeafRef) contains the text ".pdf". The function endswith() is not supported, so we can't use it in the query
       
    • FSObjType eq 0  will return Files only
       
    • FileLeafRef asc - sorts the output by filename, in ascending order.
       
    • Then, you could use the Filter Array action "Only keep items where Name ends with .pdf" - as a quality check.
     
    For more info, see:
     
    1. Power Automate: Get Only Files (Exclude Folders) from a SharePoint Library – Ellis Karim's Blog
    2. How to Find the Internal Name of a SharePoint Column (Step-by-Step Guide) – Ellis Karim's Blog
     
    Ellis Karim
    Ellis Karim
    Blog | LinkedIn | Bluesky
    If this solved your issue, please mark it as ✅ Accepted Answer. If it helped, feel free to give it a 🩷 Like!

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard