bisect-kit: fix the order when applying commits

 - Python3's sort() is stricter to reject raw object comparison
 - Regarding correctness, the ordering actually doesn't matter; however
   it's good to have deterministic order

BUG=b:140004822
TEST=bisect chromeos local build manually

Change-Id: I9b2105a458c97138c3fbfcbd9359cdd7a38a11ca
diff --git a/bisect_kit/codechange.py b/bisect_kit/codechange.py
index 5ab0618..12ff251 100644
--- a/bisect_kit/codechange.py
+++ b/bisect_kit/codechange.py
@@ -440,7 +440,7 @@
   commits = {}
 
   def batch_apply(commits):
-    for i, commit_action in sorted(commits.values()):
+    for i, _, commit_action in sorted(commits.values(), key=lambda x: x[:2]):
       logger.debug('[%d] applying "%r"', i, commit_action.summary(code_storage))
       commit_action.apply(code_storage, root_dir)
 
@@ -450,8 +450,8 @@
         break
     else:
       # If all actions are commits, defer them for batch processing.
-      for action in action_group.actions:
-        commits[action.path] = (i, action)
+      for j, action in enumerate(action_group.actions):
+        commits[action.path] = (i, j, action)
       continue
 
     batch_apply(commits)