Skip to content

Commit ec8dd16

Browse files
committed
fix
R tutorials order
1 parent 2ae5bcd commit ec8dd16

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/extensions/filterlist.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,19 @@ def process_card_nodes(app, doctree, fromdocname):
186186
if not hasattr(env, "all_cards"):
187187
env.all_cards = []
188188

189+
# Sort the cards by numeric prefix (if present) and then by source file path and line number
190+
def extract_numeric_prefix(filename):
191+
# Extract the numeric prefix from the file name, default to a large number if no prefix
192+
parts = filename.split("_", 1)
193+
try:
194+
return int(parts[0])
195+
except ValueError:
196+
return float("inf") # Treat files without a numeric prefix as the largest
197+
189198
# Sort the cards by source file path and line number
190199
env.all_cards.sort(
191200
key=lambda card: (
201+
extract_numeric_prefix(card.source), # Numeric prefix
192202
card.source, # Source file path
193203
card.line, # Line number in the source file
194204
)

0 commit comments

Comments
 (0)