I recently learnt that in order to sort a hastable, you need to prefix the construction of the hash with [ordered] (works for Powershell Version 3+).
eg, to create an empty hash:
$allCounts = [ordered]@{}
This works as desired, but I don't really understand why this works. What is [ordered]; what other of these attributes are supported and what language contructs can these attributes be applied to? It looks a bit like the attribute that you can assign to function parameters, but I think this is a different construct than the ordered attribute, but I'm not sure.
Thanks.