title: Left padding a string to sort accordingly
body: <p>I have to get the database with the max space free in a exchange 2010 however as this gonna be launched from a pipeline in c#, I'm trying to sort the results and then pick the first row. </p>
  
  <p>If I try using the field <strong>AvailableNewMailboxSpace</strong>, it is sorted using the string values instead the double values:</p>
  
  <pre><code> Get-MailboxDatabase  -Status | Select Name,AvailableNewMailboxSpace | Sort-Object DatabaseSize
  
  Name           AvailableNewMailboxSpace    
  ----           ------------------------    
  DBMB03         123.1 MB (129,073,152 bytes)
  DBMB04         114.1 MB (119,635,968 bytes)
  DBMB02         115.6 MB (121,176,064 bytes)
  DBMB10         224.4 MB (235,307,008 bytes)
  DBMB01         81.47 MB (85,426,176 bytes) 
  </code></pre>
  
  <p>I guess I must left pad zeros in the string to get the right order but I don't know how. </p>
  
  <p>I have to achieve it in a single line because this gonna be launched using a pipeline command in c#. </p>
  
  <p>This is my attempt:</p>
  
  <pre><code>Get-MailboxDatabase  -Status |`
  Sort (("0" * (10 - {$_.AvailableNewMailboxSpace.Substring(0, $_.AvailableNewMailboxSpace.IndexOf("MB") - 1)}.length)) + `
  {$_.AvailableNewMailboxSpace.Substring(0, $_.AvailableNewMailboxSpace.IndexOf("MB") - 1)}) | Select Name,AvailableNewMailboxSpace
  </code></pre>