Open jessetan opened 7 years ago
Would be a nice addition, for things like release notes, where one might want to have one .rst
file per version, right now I'm listing the files manually in the natural order for that.
+1: Reasonable.
Is there any objection to moving forward with this? It would a useful improvement for my team too.
When using a toctree with the
glob
option, the filenames in the list are sorted using Python'ssorted()
, which does lexicographical sorting. An example result would be:This is because in lexicographical sorting 1 < 2, hence
item10
will come beforeitem2
. The sorting differs from what operating systems typically do, which would be:This order makes more sense for humans.
The easiest way to implement this would be to add a new option to the toctree directive (e.g.
:natsort:
) that replacessorted()
withnatsorted()
from the Natsorted module. Just changing the behavior without an option is possible but will generate a different order for some document. I can make a PR for this, but only if there are no objections that: