title: Sort PowerShell dynamic parameters in descending order
body: <p>I have a script that displays changes from an array and an hashtable. The changes are displayed according to scriptnames or change dates.</p>
  
  <p>When called from PS-concole I have the changes listed as dynamic parameters to make it easier to show specific date. But this list is in ascending order, thus 2019-12-30 comes before 2020-01-01. If there are many dates, the most recent will be far down in the bottom.</p>
  
  <p>Is there a way to reverse the listing in descending order of this dynamic parameter?</p>
  
  <p><strong>EDIT</strong>
  This is the code creating the parameters:</p>
  
  <pre><code>[CmdletBinding()]
  
  param ()
  
  DynamicParam
  {
      $ParamAttrib = New-Object System.Management.Automation.ParameterAttribute
      $AttribColl = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
      $AttribColl.Add($ParamAttrib)
      $AttribColl.Add((New-Object System.Management.Automation.ValidateSetAttribute($global:changeloghash.Keys)))
      $RuntimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter('SkriptChanges',  [string], $AttribColl)
  
      $ParamAttrib2 = New-Object System.Management.Automation.ParameterAttribute
      $AttribColl2 = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
      $AttribColl2.Add($ParamAttrib2)
      $changeDates = @()
      $global:changeloghash.Values.GetEnumerator() | % {$_[0]} | select -Unique | % {$changeDates += $_}
      $AttribColl2.Add((New-Object System.Management.Automation.ValidateSetAttribute($changeDates)))
      $RuntimeParam2 = New-Object System.Management.Automation.RuntimeDefinedParameter('ChangeDatum',  [string], $AttribColl2)
  
      $RuntimeParamDic = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
      $RuntimeParamDic.Add('SkriptChanges', $RuntimeParam)
      $RuntimeParamDic.Add('ChangeDatum', $RuntimeParam2)
  
      return  $RuntimeParamDic
  </code></pre>