title: How to get any numbers sorted from string variable in Java?
body: <p>How to get any number like '101010' or '001101' to '111000' in Java?
  Following is the code to be used for and edited to attain the output</p>
  
  <p>I tried putting the main logic and assigning values to line2 for output. I used line to fetch input, but it doesn't work!</p>
  
  <pre><code>/*NOTE : Class Name should be Main */
  import java.io.*;
  import java.util.*;
  class Main {
      public static void main(String[] args) throws InterruptedException {
          List&lt;String&gt; inputByLine = new ArrayList&lt;String&gt;();
          try {
              // Get the object of DataInputStream
              InputStreamReader isr = new InputStreamReader(System.in,"UTF-8");
              BufferedReader br = new BufferedReader(isr);
              String line = "";
              while ((line = br.readLine()) != null){
                  inputByLine.add(line.toString());
              }
              for (String line2 : inputByLine)
                  System.out.println(line2);
              isr.close();
          } catch (IOException ioe) {
              ioe.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>I expect the numbers to be sorted, all the ones to be on the beginning followed by the zeroes.</p>