Export-CSV and Import-CSV are great ways of persisting data in a structured way. There are some limitations, though. Take a look. This line saves a folder listing to a csv file:
You can later reload it into a variable using this line:
When you output $result, you get back the same structured information: PowerShell keeps object properties. However, this is not entirely true. When you try and sort the result by Length, you are up for a surprise:
Apparently, PowerShell now sorts alphabetically rather than numerical. As it turns out, Export/Import-CSV does preserve properties but converts them all to string.