Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

[ordered] attribute to sort hast table, but what language construct is this?

$
0
0

 

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.

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles