Do not re-sort changes on their 'written on' timestamp

ChangeMessagesUtil#byChange(notes) already returns all change
messages in chronological order, oldest first. Moreover, sorting
change messages based on their 'written on' timestamp can produce
unexpected results when several messages are written at exactly
the same timestamp.

Change-Id: I9fbdffc9f48a9f113fc75169aa41a0c218c5cf39
diff --git a/src/main/java/com/googlesource/gerrit/plugins/depends/on/ChangeMessageStore.java b/src/main/java/com/googlesource/gerrit/plugins/depends/on/ChangeMessageStore.java
index 6901c90..9d4060c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/depends/on/ChangeMessageStore.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/depends/on/ChangeMessageStore.java
@@ -15,6 +15,7 @@
 package com.googlesource.gerrit.plugins.depends.on;
 
 import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
 import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.Change;
 import com.google.gerrit.entities.ChangeMessage;
@@ -37,9 +38,7 @@
 import com.googlesource.gerrit.plugins.depends.on.extensions.DependencyResolver;
 import com.googlesource.gerrit.plugins.depends.on.formats.Comment;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
@@ -91,12 +90,7 @@
 
   public List<DependsOn> loadWithOrder(Change.Id cid) throws StorageException {
     ChangeNotes changeNote = changeNotesFactory.createCheckedUsingIndexLookup(cid);
-    List<ChangeMessage> messages = cmUtil.byChange(changeNote);
-    List<ChangeMessage> sortedChangeMessages =
-        messages.stream()
-            .sorted(Comparator.comparing(ChangeMessage::getWrittenOn).reversed())
-            .collect(Collectors.toCollection(ArrayList::new));
-    for (ChangeMessage message : sortedChangeMessages) {
+    for (ChangeMessage message : Lists.reverse(cmUtil.byChange(changeNote))) {
       Optional<List<DependsOn>> deps = Comment.from(message.getMessage());
       if (deps.isPresent()) {
         return deps.get();