title: How to sort a word "hello" using recursion in java?
body: <p>Problem is to sort the given letter of string alphabetically by using recursion in java, for example: </p>
  
  <pre><code>input: "hello"
  output: ehllo
  </code></pre>
  
  <p>I have tried this code:</p>
  
  <pre><code>public class MinSort {
  
      public static void main(String[] args) {    
          System.out.println(sort("hello"));
      }
  
      static String temp="";
      static String answer ="";
      public static String sort(String s)
      {
          temp = s.substring(0, 1);
          if(s.length()&lt;=1||s==null)
          {
              return s;
          }           
          else 
          {
              if(temp.compareTo(s.substring(1, 2))&gt;1)
              {
                  answer+=s.substring(0, 1);              
              }
  
              else 
              {
                  answer += temp;
                  temp = s.substring(1, 2);               
              }           
  
              sort(s.substring(0, s.length()-1));           
              return answer;
          }
      }
  }
  </code></pre>