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 Platform Community / Forums / Power Automate / Sort Array by Number ...
Power Automate
Answered

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,985 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,985 Most Valuable Professional on at
    Hi
     
    How big is your array of data?
     
    Thanks
  • Ellis Karim Profile Picture
    12,048 Super User 2026 Season 1 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
    12,048 Super User 2026 Season 1 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

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 889

#2
Valantis Profile Picture

Valantis 830

#3
Haque Profile Picture

Haque 505

Last 30 days Overall leaderboard