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 / Sort Array by Number ...
Power Automate
Unanswered

Sort Array by Number (Including Minus numbers)

(1) ShareShare
ReportReport
Posted on by 12
All,
 
Simple one this i think.  I have an array with one column that contains numbers that are both positive and negative
 
I have tried the Sort function and the Float function combined, but it wont sort it in order.
 
The column in question is called "Days left to next assessment"
 
A screenshot of some of the array is below
 
 
(This array will then go into a HTML table and then into an email)
Categories:
I have the same question (0)
  • Suggested answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at
    Hi
     
    Use the sort() expression
     
    sort(outputs('Compose'),'Days left to next assessment')
     
     
    Above replace the outputs('Compose') with your array of values.
     
    This will sort the array in ascending order.
     
    Thanks
  • HD-04081521-0 Profile Picture
    12 on at
    Hi Abm abm,  
     
    That doesnt quite work.  (The array I have is a  larger then the screenshot above )
     
    It sorts the minus numbers in a strange order of the first number, then the second number i.e  -109,-159,-17,-199,-21,-220 etc
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at
    Hi
     
    How big is your array of data?
     
    Thanks
  • Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at
    Hi HD-04081521-0,
     
    The 'Days left to next assessment' property is a text string and not a number, hence it will be sorted lexicographically (i.e.  it will sorted in dictionary sort order).
     
    Perhaps you can convert 'Days left to next assessment' to an integer value and then sort?
     
    Here is something you could try:
     
     
     
     
    setProperty(item(),'Days left to next assessment', int(item()?['Days left to next assessment']))
    
    sort(body('Select'),'Days left to next assessment')
     
     
     
     
    Ellis
     
     
  • HD-04081521-0 Profile Picture
    12 on at
    Hi Ellis,
     
    I tried what you did, but I got the follow JSON error message when I tried to compose that in a Select  (Screenshot below)
     
     
     
  • Verified answer
    Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at
    Hi,
     
    In the Select action, just exclude the { } from the Map:
     
     
     
  • HD-04081521-0 Profile Picture
    12 on at
    Thanks so much for that Ellis the above. The 'setProperty' function has worked and no all my minus and positive numbers are sorted in order.
     
    Why Microsoft dont let you set in in another function is just silly, but hey ho it works :)

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

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard