Hashtables and key order

后端 未结 7 1048
青春惊慌失措
青春惊慌失措 2020-12-05 17:46

Is there a way to keep the order of keys in a hashtable as they were added? Like a push/pop mechanism.

Example:

$hashtable = @{}

$hashtable.Add(\"Sw         


        
7条回答
  •  隐瞒了意图╮
    2020-12-05 18:13

    function global:sortDictionaryByKey([hashtable]$dictionary)
    {
        return $dictionary.GetEnumerator() | sort -Property name;
    }
    

提交回复
热议问题