title: Sort lines of a .txt file with PowerShell
body: <p>I have a <code>.txt</code> like that below:</p>
  
  <pre><code>MasterCard 
  R$ 66,12 
  
  Hipercard 
  R$ 7.501,98 
  
  MasterCard 
  R$ 48,19 
  
  Hipercard 
  R$ 7.742,46 
  
  MasterCard 
  R$ 48,19 
  
  Hipercard 
  R$ 5.846,14 
  
  MasterCard 
  R$ 48,19 
  
  Hipercard 
  R$ 4.210,65 
  
  Visa
  R$ 4.210,65 
  
  MasterCard 
  R$ 48,19 
  
  Hipercard 
  R$ 2.892,20 
  
  MasterCard 
  R$ 48,19 
  
  Visa
  R$ 4.210,65
  
  Hipercard 
  R$ 1.944,19 
  
  Hipercard 
  R$ 584,04 
  
  Visa
  R$ 4.210,65
  </code></pre>
  
  <p>I need a <code>.bat</code> file (could be in PowerShell) that organize the lines by the descrption and value, like below:</p>
  
  <pre><code>-----------------
  MasterCard 
  R$ 66,12 
  
  MasterCard 
  R$ 48,19 
  
  MasterCard 
  R$ 48,19 
  
  MasterCard 
  R$ 48,19 
  
  MasterCard 
  R$ 48,19 
  
  MasterCard 
  R$ 48,19 
  
  ----------------      
  Hipercard 
  R$ 7.501,98 
  
  Hipercard 
  R$ 7.742,46 
  
  Hipercard 
  R$ 5.846,14 
  
  Hipercard 
  R$ 4.210,65
  
  Hipercard 
  R$ 2.892,20 
  
  Hipercard 
  R$ 1.944,19 
  
  Hipercard 
  R$ 584,04 
  
  --------------        
  Visa
  R$ 4.210,65 
  
  Visa
  R$ 4.210,65
  
  Visa
  R$ 4.210,65
  </code></pre>
  
  <p>It's possibile do it with a <code>.bat</code> file? I'm stuck in how to start.
  I was trying using a simple command: <code>sort test.txt /o testout.txt</code></p>
  
  <p>But it's not working.</p>
  
  <hr>
  
  <p>I have another idea. Running this command i can put all lines in the same line:</p>
  
  <pre><code>for /f "usebackq tokens=* delims=" %%a in ("frt01.txt") do (echo(%%a)&gt;&gt;test.txt
  for /f "usebackqdelims=" %%i in ("test.txt") do @&lt;nul set /p"=%%i "&gt;&gt;"test2.txt"
  del test.txt /S /Q /
  </code></pre>
  
  <p>So now, the description and values are all in only one line:</p>
  
  <pre><code>MasterCard  R$ 66,12  Hipercard  R$ 7.501,98  MasterCard  R$ 48,19  Hipercard  R$ 7.742,46  MasterCard  R$ 48,19  Hipercard  R$ 5.846,14  MasterCard  R$ 48,19  Hipercard  R$ 4.210,65  MasterCard  R$ 48,19  Hipercard  R$ 2.892,20  MasterCard  R$ 48,19  Hipercard  R$ 1.944,19  Hipercard  R$ 584,04  
  </code></pre>
  
  <p>How can i do for it be like bellow? (Type a 'enter' after each value)</p>
  
  <pre><code>MasterCard  R$ 66,12  
  Hipercard  R$ 7.501,98  
  MasterCard  R$ 48,19  
  Hipercard  R$ 7.742,46  
  MasterCard  R$ 48,19  
  Hipercard  R$ 5.846,14  
  MasterCard  R$ 48,19  
  Hipercard  R$ 4.210,65  
  MasterCard  R$ 48,19  
  Hipercard  R$ 2.892,20  
  MasterCard  R$ 48,19  
  Hipercard  R$ 1.944,19  
  Hipercard  R$ 584,04  
  </code></pre>
  
  <p>Because then i can sort with this command: <code>sort test2.txt /o output.txt</code></p>
  
  <p>I guess doing by this way is easier.</p>
  
  <hr>
  
  <p>@michael_heath This is what i was talking:</p>
  
  <pre><code>Hipercard   R$    584,04
  Hipercard   R$  1.944,19
  Hipercard   R$  2.892,20
  Hipercard   R$  4.210,65
  Hipercard   R$  5.846,14
  Hipercard   R$  7.501,98
  Hipercard   R$  7.742,46
  ------------------------
  MasterCard  R$     48,19
  MasterCard  R$     48,19
  MasterCard  R$     48,19
  MasterCard  R$     48,19
  MasterCard  R$     48,19
  MasterCard  R$     66,12
  ------------------------
  Visa        R$     48,19
  Visa        R$     48,19
  Visa        R$     48,19
  ------------------------
  </code></pre>