title: VBScript - How to sort alpha-numerical string from text file by numerical value?
body: <p>My data looks like this:</p>
  
  <pre><code>9999.81GB increase - "c:\$RECYCLE.BIN"   1.91GB total
  11.54GB increase - "c:\Program Files (x86)"   11.55GB total
  101.57GB increase - "c:\Windows"   101.61GB total
  </code></pre>
  
  <p>I want it to look like this:</p>
  
  <pre><code>9999.81GB increase - "c:\$RECYCLE.BIN"   1.91GB total
  101.57GB increase - "c:\Windows"   101.61GB total
  11.54GB increase - "c:\Program Files (x86)"   11.55GB total
  </code></pre>
  
  <p>I've been trying to bubble sort this.  I assume I need to first split off the string before the first "." which will be a usable number for sorting.  I've managed that with something like this:</p>
  
  <pre><code>Const ForReading = 1
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile1 = objFSO.OpenTextFile("C:\Source.txt", ForReading)
  
  Do Until objFile1.AtEndOfStream
  FileContent = objFile1.ReadLine
  arr1 = Split(FileContent,".",2)
  arr2 = Array(arr1(0))
  
  For i=0 to UBound(arr2)
  WScript.Echo arr2(i)
  
  Next
  Loop
  </code></pre>
  
  <p>But instead of echoing, I need to use these values in the bubble sort.  This is where I seem to be stuck.</p>
  
  <p>I'm open to using a different type of sort.. but there will never be many lines to sort so I figured bubble might be a good choice.</p>
  
  <p>Here is the best I've been able to do:</p>
  
  <pre><code>Const ForReading = 1
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objOpen = objFSO.OpenTextFile("C:\Source.txt", ForReading)
  
  Do Until objOpen.AtEndOfStream
  FileContent = objOpen.ReadLine
  arr1 = Split(FileContent,".",2)
  arr2 = Array(arr1(0))
  
  Do
  x = UBound(arr2)
    y = -1
    For j = LBound(arr2) to x - 1
        If arr(j) &gt; arr2(j + 1) Then
           TempValue = arr2(j + 1)
           arr2(j + 1) = arr2(j)
           arr2(j) = TempValue
           y = j
        End If
    Next
    x = y
  Loop Until y = -1
  
  z = ""
  For i = UBound(arr2) To LBound(arr2)
      z = z &amp; arr2(i) &amp; "." &amp; arr1(1) &amp; vbCrlf
  
  Next  
  Loop
   WScript.echo z 
  </code></pre>
  
  <p>But this outputs only the last line and it doesn't appear to have even tried to sort.</p>
  
  <p>I'm new at this :)  Any help would be greatly appreciated.</p>
  
  <p>Arthur</p>