title: Sort array based on count of occurrences in ascending order
body: <p>How can I arrange the elements in an array based on the number of occurrences of that value in ascending order in java.</p>
  
  <p>This is what I've tried:</p>
  
  <pre><code>int a[]={0,0,0,1,3,3,2,1,3,5,6,0};
  int b=a.length;
  for(int i=0;i&lt;b;i++) {
      for(int j=0;j&lt;i;j++) {
          int temp;
          if( a[j]&gt;a[i]) {
              temp=a[i];
              a[i]=a[j];
              a[j]=temp;
          }
      }
  }
  
  for(int r=0;r&lt;a.length;r++) {
      System.out.println(a[r]);
  }
  </code></pre>