Trying to run range (readDir $path), but file list is sorted 1, 10, 100, 101, etc

Try this solution out: Order pages by the id

As for why: you are sorting strings; “A1” < “A1000” < “A2”.