diff --git a/Task.java b/Task.java index 9f52da4..1a58c3c 100644 --- a/Task.java +++ b/Task.java @@ -63,16 +63,17 @@ public class Task { int length = Math.min(tokens1.length, tokens2.length); for (int i = 0; i < length; i++) { - if (Character.isLetter(tokens1[i].charAt(0)) && Character.isLetter(tokens2[i].charAt(0))) { - int stringCompare = tokens1[i].compareTo(tokens2[i]); - - if (stringCompare != 0) - return stringCompare; - } else { + if (Character.isDigit(tokens1[i].charAt(0)) && Character.isDigit(tokens2[i].charAt(0))) { int intCompare = Integer.compare(Integer.parseInt(tokens1[i]), Integer.parseInt(tokens2[i])); - - if (intCompare != 0) + + if (intCompare != 0) return intCompare; + } else { + + int stringCompare = tokens1[i].compareTo(tokens2[i]); + + if (stringCompare != 0) + return stringCompare; } } diff --git a/Week9.java b/Week9.java index fe76193..f1b60ce 100644 --- a/Week9.java +++ b/Week9.java @@ -154,6 +154,7 @@ public class Week9 { // Test tasks, not read from a file and are not intended to be saved to a file. private void testData() { tasks.add(new Task("Title 1000", "Description ", "Due Date ")); + tasks.add(new Task("100 Title", "Description ", "Due Date ")); for (int i = 20; i > 0; i--) tasks.add(new Task("Title " + i, "Description " + i, "Due Date " + i)); }