Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions marimo/_utils/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
from pathlib import Path
from typing import Union

_num_split = re.compile("([0-9]+)").split

def natural_sort(filename: str) -> list[Union[int, str]]:
def convert(text: str) -> Union[int, str]:
return int(text) if text.isdigit() else text.lower()

def alphanum_key(key: str) -> list[Union[int, str]]:
return [convert(c) for c in re.split("([0-9]+)", key)]

return alphanum_key(filename)
def natural_sort(filename: str) -> list[Union[int, str]]:
return [int(c) if c.isdigit() else c.lower() for c in _num_split(filename)]


def get_files(folder: str) -> Generator[Path, None, None]:
Expand Down