I have a .txt file something like this:
First, Second, Third, Fourth, -32
First-a, Second-a, Third-a, Fourth-a, 98
First-b, Second-b, Third-b, Fourth-b, 32
First-c, Second-c, Third-c, Fourth-c, 1
First-d, Second-d, Third-d, Fourth-d, -20
I have the following code for sorting:
$Line = $_.Trim() -Split ','
New-Object -TypeName PSCustomObject -Property @{
fst = $Line[0]
snd = $Line[1]
thrd = $Line[2]
frth = $Line[3]
fifth = [int]$Line[4]
}
} | Sort-Object -Descending fifth | Write-Host
So this would have to display this:
First-a, Second-a, Third-a, Fourth-a
Since 98 is the highest number