@Override
  public int compareTo(ID o) {
    TaskID that = (TaskID)o;
    int jobComp = this.jobId.compareTo(that.jobId);
    if(jobComp == 0) {
      if(this.type == that.type) {
        return this.id - that.id;
      }
      else {
        return this.type.compareTo(that.type);
      }
    }
    else return jobComp;
  }
@Test
  public void testCompareTo() {
    JobID jobId = new JobID("1234", 1);
    TaskID taskId1 = new TaskID(jobId, TaskType.REDUCE, 0);
    TaskID taskId2 = new TaskID(jobId, TaskType.REDUCE, 0);

    assertEquals("The compareTo() method returned non-zero for two equal "
        + "task IDs", 0, taskId1.compareTo(taskId2));

    taskId2 = new TaskID(jobId, TaskType.MAP, 1);

    assertTrue("The compareTo() method did not weigh task type more than task "
        + "ID", taskId1.compareTo(taskId2) > 0);

    TaskType[] types = TaskType.values();

    for (int i = 0; i < types.length; i++) {
      for (int j = 0; j < types.length; j++) {
        taskId1 = new TaskID(jobId, types[i], 0);
        taskId2 = new TaskID(jobId, types[j], 0);

        if (i == j) {
          assertEquals("The compareTo() method returned non-zero for two equal "
              + "task IDs", 0, taskId1.compareTo(taskId2));
        } else if (i < j) {
          assertTrue("The compareTo() method did not order " + types[i]
              + " before " + types[j], taskId1.compareTo(taskId2) < 0);
        } else {
          assertTrue("The compareTo() method did not order " + types[i]
              + " after " + types[j], taskId1.compareTo(taskId2) > 0);
        }
      }
    }

    try {
      taskId1.compareTo(jobId);
      fail("The compareTo() method allowed comparison to a JobID object");
    } catch (ClassCastException ex) {
      // Expected
    }

    try {
      taskId1.compareTo(null);
      fail("The compareTo() method allowed comparison to a null object");
    } catch (NullPointerException ex) {
      // Expected
    }
  }