WebHost: Fix world sorting in /tutorial/ #5785
Open
+7
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


What is this fixing or adding?
While there is an attempt to
title_sortedthe worlds, it's done on the wrong dict.tutorialsis never iterated; it's only accessed by index (viatutorials[world_name].items()) thus its order does not matter. The dict that needs to be sorted isworlds, as that's what's iterated (via% for world_name, world_type in worlds.items() %})As a result, on main the worlds on the tutorial page are not title_sorted like they are in the Supported Games list (notice how on https://archipelago.gg/tutorial/ "A Hat in Time" and "A Link to the Past" are both sorted with the As rather than with the Hs and Ls respectively).
In addition,
worlds/__init__.pyloads all world sources first, then all apworlds.AutoWorldRegister.world_typesis a dict which as of Python 3.7 maintains insertion order. If a custom WebHost is adding additional worlds via custom_worlds, those will all be after any worlds from the worlds/ folder. Sinceworldsis never sorted, when rendering/tutorial/on the WebHost, all custom worlds end up coming after all worlds in worlds/:How was this tested?
Confirmed locally that "Archipelago" is still first:
And that "A Hat in Time" is now sorted with the Hs:
Put
pokemon_frlg.apworldincustom_worlds. Loaded the webhost before the change, see screenshot above. Loaded after the change: