title: How to sort numbers in TextViews and display them?
body: <p>Hi can some one suggest me a sample example of how i can sort the textviews based on the numbers in textviews. I am able to get the text from the TextViews need to sort and place the lowest number first.</p>
  
  <p>Thank you.</p>
  
  <pre><code>public void sortNumbers(View v) {
  
      String[] numbers = new String[7];
      numbers[0] = textView23.getText().toString();
      numbers[1] = textView33.getText().toString();
      numbers[2] = textView43.getText().toString();
      numbers[3] = textView53.getText().toString();
      numbers[4] = textView63.getText().toString();
      numbers[5] = textView73.getText().toString();
      numbers[6] = textView83.getText().toString();
  
      Integer[] intValues = new Integer[numbers.length];
      for (int i = 0; i &lt; numbers.length; i++) {
          intValues[i] = Integer.parseInt(numbers[i].trim());
      }
      Collections.sort(Arrays.asList(intValues));
  
      for (int i = 0; i &lt; intValues.length; i++) {
          Integer intValue = intValues[i];
  
          //here I want to assign sorted numberes to the TextViews
  
  
      }
  
  }
  </code></pre>
  
  <hr>
  
  <p>So I have followed Jeffrey's advice. Here is the code which still doesn't work properly. What could be wrong?</p>
  
  <p>Created an array of TextViews:</p>
  
  <pre><code>TextView[] tvs = new TextView[7];
  
      tvs[0] = textView23;
      tvs[1] = textView33;
      tvs[2] = textView43;
      tvs[3] = textView53;
      tvs[4] = textView63;
      tvs[5] = textView73;
      tvs[6] = textView83;
  </code></pre>
  
  <p>Sorted the array and assinged new values to the TextViews:</p>
  
  <pre><code>    Arrays.sort(tvs, new TVTextComparator());
  
      textView23.setText(tvs[0].getText().toString());
      textView33.setText(tvs[1].getText().toString());
      textView43.setText(tvs[2].getText().toString());
      textView53.setText(tvs[3].getText().toString());
      textView63.setText(tvs[4].getText().toString());
      textView73.setText(tvs[5].getText().toString());
      textView83.setText(tvs[6].getText().toString());    
  </code></pre>
  
  <p>And here is the Comporator class:</p>
  
  <pre><code>public class TVTextComparator implements Comparator&lt;TextView&gt; {
      public int compare(TextView lhs, TextView rhs) {
  
          Integer oneInt = Integer.parseInt(lhs.getText().toString());
          Integer twoInt = Integer.parseInt(rhs.getText().toString());
  
          return oneInt.compareTo(twoInt);
      }
  }
  </code></pre>