title: grouping files by size with powershell
body: <p>i have a directory and want to group (copy them somewhere) them (in three groups) by size</p>
  
  <p>given:</p>
  
  <pre><code>c:\temp\dir
  
  a.txt 200kb
  b.txt 220kb
  c.txt 230kb
  d.txt 250kb
  e.txt 270kb
  f.txt 280kb
  g.txt 290kb
  h.txt 310kb
  </code></pre>
  
  <p>i list these files and put them in three seperate groups by simply iterating them (right now i just print output, but lets keep things simply): </p>
  
  <pre><code>$dir = Get-ChildItem c:\temp\dir\*.*
  $count = 0;
  foreach( $file in $dir)
  {
      if ($count -eq 0)
      {
          write-output "1) $file"
      }
  
      if ($count -eq 1)
      {
          write-output "2) $file"
      }
  
      if ($count -eq 2)
      {
          write-output "3) $file"
      }
  
      $count = $count + 1
  
      if ($count -gt 2){
          $count = 0
      }
  
  }
  </code></pre>
  
  <p>my question is: how can i sort the list by file size?<br> is there a way to tell <code>$dir = Get-ChildItem c:\temp\dir\*.*</code> to be ordered by file size?</p>