How to sort integer array without losing location
<p>I'm making a program which receives a string as input and returns the "sum" of the values for each letter of each word.</p>

<p>For example, my input of <code>"Take advantage, do your best, don't stress."</code>, would return:</p>

<pre><code>do(19) take(37) dont(43) best(46) advantage(75) your(79) stress(100)
</code></pre>

<p><code>"do"</code> would have a value of 19 because the letter <code>"d"</code> has a value of 4 (it is the fourth letter of the alphabet), and "o" has a value of 15, so the total is 19.</p>

<p>Now to store these values I have two arrays, one string array for each word, and one int array for the point value that they have. However, I only have this so far:</p>

<pre><code>take(37) advantage(75) do(19) your(79) best(46) dont(53) stress(100) 
</code></pre>

<p>As you can see, it is not sorted in ascending order as I am trying to do. I display these values like this:</p>

<pre><code>System.out.print(words[j] + "(" + points[j] + ")" + " ");
</code></pre>

<p>where words is the String array and points is the int array. How can I sort them?</p>

<p>My current code:</p>

<pre><code>public static void main (String[] args)
{
    String input = "Take advantage, do your best, don't stress.";
    String output = "";


    //Get rid of all punctuation
    for(int i = 0; i &lt; input.length(); i++){
        if(   ( (int)input.charAt(i) &gt;= 65 &amp;&amp; (int)input.charAt(i) &lt;= 90) || (int)input.charAt(i) == 32  || ( (int)input.charAt(i) &gt;= 97 &amp;&amp; (int)input.charAt(i) &lt;= 122)){

            //Handles Uppercase
            if(input.charAt(i) &gt;= 65 &amp;&amp; input.charAt(i) &lt;= 90){
                int temp = (int)input.charAt(i) + 32;
                char c = (char)temp;
                output += c;
            }
            //Handles all other characters
            else{
                output += input.charAt(i);
            }
        }
    }
    //Done punctuation

    String[] words = output.split(" ");
    int[] points = new int[words.length];

    //Points assignment
    for(int j = 0; j &lt; words.length; j++){
        for(int k = 0; k &lt; words[j].length(); k++){
            points[j] += (int)words[j].charAt(k) - 96;
        }
        System.out.print(words[j] + "(" + points[j] + ")" + " ");
    }
}
</code></pre>