From 5e483dc16626b937f24bc10c90dedf8e1e92003e Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 16 May 2026 15:29:46 -0400
Subject: [PATCH] android: Build the APK asset tree in the same order its
listed in the file.
This tends to get you enumerations in alphabetical order, instead of them
being reverse-alphabetical.
Reference Issue #15587.
---
src/core/android/SDL_android.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 7e97794cb3951..aada4584811c7 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -1875,6 +1875,7 @@ typedef struct APKNode
SDL_PathInfo info;
struct APKNode *parent;
struct APKNode *children;
+ struct APKNode *children_tail;
struct APKNode *next_sibling;
} APKNode;
@@ -1983,8 +1984,12 @@ static APKNode *AddAPKChildNode(APKNode *parent, const char *child)
SDL_copyp(&node->info, &parent->info); // you probably need to update this afterwards.
node->parent = parent;
- node->next_sibling = parent->children;
- parent->children = node;
+ if (parent->children_tail) { // APKs tend to be sorted alphabetically, so insert new nodes at the end of the list to maintain this order.
+ parent->children_tail->next_sibling = node;
+ } else {
+ parent->children = node;
+ }
+ parent->children_tail = node;
}
return node;
}