PowerShell: How do I sort a text file by column?

Question:

I want to sort a text file in PowerShell. The text file looks like this:

I want to output that file like this:

As you can see, it is ordered descending by the number associated to the name.How do I do that?

Answer:

You can sort by an expression, split each line (space delimiter), cast the last item to system.double and sort on it:

Source:

PowerShell: How do I sort a text file by column? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply