title: Sort a PowerShell hash table on a property of the value
body: <p>I'm having an issue sorting a hash table.  I've broken down my code to just bare necessities so as not to overwhelm anyone with my original script.</p>
  
  <pre><code>Write-Host "PowerShell Version = " ([string]$psversiontable.psversion) 
  $h = @{}
  $Value = @{SortOrder=1;v1=1;}
  $h.Add(1, $Value)
  $Value = @{SortOrder=2;v1=1;}
  $h.Add(2, $Value)
  $Value = @{SortOrder=3;v1=1;}
  $h.Add(3, $Value)
  $Value = @{SortOrder=4;v1=1;}
  $h.Add(4, $Value)
  
  Write-Host "Ascending"
  foreach($f in $h.GetEnumerator() | Sort-Object Value.SortOrder)
  {
      Write-Host $f.Value.SortOrder
  }
  
  Write-Host "Descending"
  foreach($f in $h.GetEnumerator() | Sort-Object Value.SortOrder -descending)
  {
      Write-Host $f.Value.SortOrder
  }
  </code></pre>
  
  <p>The output is </p>
  
  <pre><code>PowerShell Version =  3.0
  Ascending
  2
  1
  4
  3
  Descending
  2
  1
  4
  3
  </code></pre>
  
  <p>I'm sure this is just a simple case of not knowing the correct usage of <code>Sort-Object</code>.  The sort works correctly on <code>Sort-Object Name</code> so maybe it has something to do with not knowing how to handle the <code>Value.SortOrder</code>?</p>