Use natural order for git branches in cherry pick check

Bug: b/402014973
Change-Id: I936ac3f7f651347c3a55ef394fe1157f32686875
Fixes: 402014973
diff --git a/tools/check-cherry-picks.py b/tools/check-cherry-picks.py
index 3b27b08..85d1acb 100755
--- a/tools/check-cherry-picks.py
+++ b/tools/check-cherry-picks.py
@@ -53,14 +53,17 @@
         return True
     return False
 
-
 # Find all release branches between OLDEST_BRANCH and DEV_BRANCH
 def get_release_branches():
     # Release branches are assumed to be of the form 'origin/X.Y'
     out = run_cmd(['git', 'branch', '-r', '-l'])
-    pattern = re.compile('origin/(\d+).(\d+)')
+    natsort = lambda s: [int(t) if t.isdigit() else t.lower()
+                         for t in re.split(r'(\d+)', s)]
+    lines = sorted(out.split('\n'), key=natsort)
+    pattern = re.compile(r'origin/(\d+).(\d+)')
     releases = []
-    for line in out.split('\n'):
+
+    for line in lines:
         m = pattern.search(line.strip())
         if m:
             major = m.group(1)