Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Sort a list but have 2 specific objects at the top

$
0
0

I think I got it. . .

# Put the 2 I want on top of a temp file
“peach” | Out-File .\step2.txt -Force
“grapefruit” | Out-File .\step2.txt -Append

# Get the list I can’t control and append it after my top 2
Get-Content .\unsorted.txt | Sort-Object | Out-File .\step2.txt -Append

# Sort the temp file and exclude duplicates
Get-Content .\step2.txt | Select-Object -Unique

# I promise Don Jones I will learn to work with arrays that have carriage returns in them
# Currently I only know comma separated arrays


Viewing all articles
Browse latest Browse all 13067

Trending Articles