Sort by condition input with ArrayList Android
<p>I have a arraylist with two field Name and Year. I want to sort this array with condition input name (sort by name input). If the name is same it will sort by year. </p>

<pre><code>Example
Name     Year
Ann      2000
Bech     2001
Bach     2013
Bach     2012
Chu      1999
</code></pre>

<p>Assume that I create a function is sort with input is Bach. The result will display </p>

<pre><code>Name     Year
Bach     2013
Bach     2012
Ann      2000
Bech     2001
Chu      1999
</code></pre>

<p>Because with input is Bach and the first I want to display all name with "Bach" If the same name I will sort it by year(largest-smallest). If don't same "Bach" name I will sort by A-Z using compareTo()
This is my code but I don't have input condition name . Please make a new function help me same sort_inputname(String inputname)</p>

<pre><code>    //Class compare Name- Year
public class Search_Name_Year_Comparator implements Comparator&lt;SearchListInformation&gt;
{


            public int compare(SearchListInformation left,
                    SearchListInformation right) {
                // TODO Auto-generated method stub
                 int dateComparison;
                    int dataComparison = 0;
        if(left.getName().compareTo(right.getName())==0)
            {
             if(left.getYear().compareTo(right.getYear())&gt;0)
             {
             return -1;
             }
             else if(left.getYear().compareTo(right.getYear())&lt;0)
             {
                 return  1;
             }
             else 
                 return 0;


             }
        else
         return  left.getName().compareTo(right.getName());
</code></pre>
