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

Thanks Don,

Looking forward to the podcast tonight for sure. OK so here we go I think I learned something here. . .

$topmost = ‘peach’,'grapefruit’
$main = ‘apple’,'orange’,'peach’,'pear’,'grapefruit’
$sorted_main = $main | Sort-Object
$topmost+$sorted_main | Select-Object -unique

In my real word array of strings the duplicates are going to be there so I joined (+) topmost and sorted main so I could filter out the duplicates. The variable we are calling “main” is a list of objects from a registry key I can not predict or control and the 2 objects I want sorted to the top are already in there. So I like this and I think you have helped me greatly and now I don’t have to rely on saving to a file and getting content out of a file to sort my list and what I posted above works exactly like I need. Thanks again this is awesome!

-VERN


Viewing all articles
Browse latest Browse all 13067

Trending Articles