 <p>I have created an example where you can sort your ArrayList even if its with objects. You can read through it an see if it's helps.</p> <p>I have made two classes and a test class:</p> <p>First class is Country:</p> <pre><code>public class Country { private String countryName; private int number; public Country(String countryName, int number){ this.countryName = countryName; this.number = number; } public String getCountryName(){ return countryName; } public void setCountryName(String newCountryName){ countryName = newCountryName; } public int getNumber(){ return number; } public void setNumber(int newNumber){ number = newNumber; } public String toString(){ return getCountryName() + getNumber(); } } </code></pre> <p>Next class is Methods:</p> <pre><code>public class Methods { private Country country; private ArrayList&lt;Country&gt; overview = new ArrayList&lt;Country&gt;(); private ArrayList&lt;Country&gt; overviewSorted = new ArrayList&lt;Country&gt;(); int [] test; public void regCountry(String countryname, int numbers){ if(!(countryname == "" &amp;&amp; numbers == 0)){ overview.add(new Country(countryname, numbers)); } else { System.out.println("The input was null"); } } public void showRegisteredCountries(){ if(!(overview.size() &lt; 0)){ for(int i = 0; i &lt; overview.size(); i++){ System.out.println("The country: " + overview.get(i).getCountryName() + " has the number: " + overview.get(i).getNumber() + " registered"); } } else { System.out.println("There are no country registered"); } } public void numbersOverFromArrayList(){ if(!(overview.size() &lt; 0)){ test = new int [overview.size()]; for(int i = 0; i &lt; overview.size(); i++){ test[i] = overview.get(i).getNumber(); } } } public void sortArrayAndCopyItBack(){ if(!(test.length &lt; 0)){ java.util.Arrays.sort(test); for(int i = 0; i &lt; test.length; i ++){ for(int j = 0; j &lt; overview.size(); j++){ if(test[i] == overview.get(j).getNumber()){ overviewSorted.add(new Country(overview.get(j).getCountryName(), overview.get(j).getNumber())); } } } } } public void showTableSorted(){ if(!(overviewSorted.size() &lt; 0)){ for(int i = 0; i &lt; overviewSorted.size(); i++){ System.out.println("Country name: " + overviewSorted.get(i).getCountryName() + " with number: " + overviewSorted.get(i).getNumber()); } } else { System.out.println("There are non countrys in table that is sorted"); } } } </code></pre> <p>Next is the test class:</p> <pre><code>public class test2 { public static void main(String [] args){ Methods methodes = new Methods(); for(int i = 0; i &lt; 4; i++){ String inCountry = JOptionPane.showInputDialog("Country:"); String inNumber = JOptionPane.showInputDialog("number:"); String country = inCountry; int number = Integer.parseInt(inNumber); methodes.regCountry(country, number); } methodes.showRegisteredCountries(); methodes.numbersOverFromArrayList(); methodes.sortArrayAndCopyItBack(); methodes.showTableSorted(); } } </code></pre> <p>My output:</p> <pre><code>The country: Norway has the number: 5 registered The country: Sweden has the number: 2 registered The country: Denmark has the number: 9 registered The country: Finland has the number: 7 registered Country name: Sweden with number: 2 Country name: Norway with number: 5 Country name: Finland with number: 7 Country name: Denmark with number: 9 </code></pre>