OUTGridData Sorting

Hello,

I am importing a csv and displaying it through Out-UDGridData. For the most part this has been working really well. Except for sorting numbers with this one particular grid. For some reason I am trying to sort numbers it is not sorting them in the correct order.

For example it is sorting them as follows

1
111
111111
1234
2
3
4
4323
5

Do you have any ideas why?

You need to sort them numerically before passing to Out-UDGridData.

PS> $numbers= 1,111,111111,1234,2,3,4,4323,5
PS> $numbers | Sort-Object {[int]$_} 

1
2
3
4
5
111
1234
4323
111111

1 Like

Below is my code. I am not sure if it is because I am importing from a csv but for some reason the dates and most columns I am unable to sort in order. I did try piping it to Sort-Object {{int]$_} however it did not work.

New-UDHtml -Markup "<div class='center-align white-text'><h3>Exchange Mailbox Counts</h3></div>"                       
                    New-UDColumn -Size 12 -Content { 
  New-UdGrid -BackgroundColor "white" -pagesize 15 -Title  "Exchange Mailboxes by OU" -FontColor "black" -Headers @("Date","TotalMailboxes","UserMailboxes","STLMailboxes","DisabledUserMailboxes","OnHoldMailboxes","SharedMailboxes","RoomMailboxes","AdminMailboxes","ServiceActMailboxes","DisabledServiceActMailboxes") -Properties @("Time","TotalMailboxes","UserMailboxes","STLMailboxes","DisabledUserMailboxes","OnHoldMailboxes","SharedMailboxes","RoomMailboxes","AdminMailboxes","ServiceActMailboxes","DisabledServiceActMailboxes") -AutoRefresh -RefreshInterval 600 -Endpoint {  
                $mbxoucounts = Import-Csv C:\Dashboard\Mailboxcount.csv | Select Time,TotalMailboxes,"UserMailboxes","STLMailboxes","DisabledUserMailboxes","OnHoldMailboxes","SharedMailboxes","RoomMailboxes","AdminMailboxes","ServiceActMailboxes","DisabledServiceActMailboxes" |  Out-UDGridData
                $mbxoucounts 
                     }

Do you have any ideas?

Hi guys, I hope this helps, but when I use the grid I sort it using the -DefaultSortColumn parameter and sorting always works how I expect it

New-UDGrid -Headers @("BiggestGross","Depot","ProductName","Quantity","Sales","Gallons","Profit","DiscountedProfit") -Properties @("BiggestGross","Depot","ProductName","Quantity","Sales","Gallons","Profit","DiscountedProfit") -DefaultSortColumn "Depot" -PageSize 20 -BackgroundColor "#ffffff" -FontColor "#000000" -Endpoint {.....