I am not sure if this will help out at all, but you can try this. Copy your data to a .csv file with your data matching format below. The data would be separated by rows and columns. DO NOT PUT ALL DATA INTO A ROW.
Name Value
Nitin 20
Nitin 30
David 20
...
Then run this. It sorted the people names by name and value. I couldn’t figure out a way to sort it by value only or to combine the values, but the output still may help.
I did not write this PS script myself. I used it from “ProvidingCredit=@SPJeff,Title=DataTable in PowerShell for crazy fast filters.” If you google what I provided there you can view his blog post & code.
I enjoyed decoding your PowerShell. I didn’t know you could pass in your data like that into the “Convertfrom-CSV” cmdlet. I learned something new today. Your approach for solving this was by far much easier and smarter then my earlier response.
My explanation below.
'Adarsh, 50
Nitin, 69
Nitin, 72
Rohit, 23
Adarsh, 90
Bumrah, 312
Rohit, 45
Bumrah, 69
Rohit, 79
Adarsh, 87
Nitin, 99
Atul, 50'-split"`n" | `
convertfrom-csv -Delimiter ','-Header 1,0 | ` #Set Delimiter as "," to separate and provide headers 1,0
group '1' | ` #Group values by column 1 which is by Name
ForEach-Object {$1=$_.group;$1.0|measure -Minimum -Maximum|Select @{n='Name';e={$1[0].1}},M*} ## Foreach Object Measure Min & Max then Select Min & Max by name and output