title: How do you sort a 2D array in ascending order by the 3rd column in java?
body: <p>My code is intended to sort a list of employees, first sorting by department (first column) and then sorting by age (third column) in ascending order.  I have searched for hours to no avail.  My code so far:</p>
  
  <pre><code>    public class Company
      {
      public static void main(String[] args)
      {
          String[][] departmentList = new String[13][3];
              departmentList[0][0] = "Accounting";
              departmentList[0][1] = "Counting Guru";
              departmentList[0][2] = "55";
              departmentList[1][0] = "Accounting";
              departmentList[1][1] = "Counting Pro";
              departmentList[1][2] = "45";
              departmentList[2][0] = "Accounting";
              departmentList[2][1] = "Counting Savvy";
              departmentList[2][2] = "40";
              departmentList[3][0] = "Accounting";
              departmentList[3][1] = "Counting Novice";
              departmentList[3][2] = "25";
              departmentList[4][0] = "Marketing";
              departmentList[4][1] = "Sales Guru";
              departmentList[4][2] = "50";
              departmentList[5][0] = "Marketing";
              departmentList[5][1] = "Sales Pro";
              departmentList[5][2] = "48";
              departmentList[6][0] = "Marketing";
              departmentList[6][1] = "Sales Savvy";
              departmentList[6][2] = "38";
              departmentList[7][0] = "Human Resources";
              departmentList[7][1] = "Hiring Guru";
              departmentList[7][2] = "58";
              departmentList[8][0] = "Human Resources";
              departmentList[8][1] = "Hiring Pro";
              departmentList[8][2] = "47";
              departmentList[9][0] = "Information Systems";
              departmentList[9][1] = "Hacking Pro";
              departmentList[9][2] = "46";
              departmentList[10][0] = "Information Systems";
              departmentList[10][1] = "Hacking Guru";
              departmentList[10][2] = "51";
              departmentList[11][0] = "Information Systems";
              departmentList[11][1] = "Hacking Savvy";
              departmentList[11][2] = "38";
              departmentList[12][0] = "Information Systems";
              departmentList[12][1] = "Hacking Novice";
              departmentList[12][2] = "23";
  
          for(int row = 0; row &lt; departmentList.length; row++)
          {
              System.out.println(departmentList[row][0] + "\t" + departmentList[row][1] + "\t" + departmentList[row][2]);
          }
      }
  }
  </code></pre>
  
  <p>I want the output to print the list according to department and then according to age, youngest to oldest.  Any help is appreciated.</p>