natsort: '_' can't be right sorted in Windows
In windows OS, I want to sorted files in a content with a natural way. But I found your code seems to be not well done in windows. The '_' is sorted after number '0-9'. But in windows OS, the '_' is showed before number '0-9'.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 27 (16 by maintainers)
OK - I have finally decided how I want to implement this.
winsortedandwinsort_keyinto the APIalgoption for customization of the results (though I will still providekey)It does seem that Microsoft has a custom sorting order for characters (at least for Excel) as can be seen in the table given here. In this table the
_character appears before numbers, which is not how it appears in the ASCII table. This is why Python’ssorted(and thusnatsorted) places the_character after and not before number characters.Having said this, it’s not clear to me what the request is here. As filed, the issue simply states that
natsortis “not well done in windows” and points out the behavior ofnatsortedcompared to Windows Explorer. Is thisnatsortreturn the same results as Windows Explorer?@ganego It’s out -
natsort7.1.0.Well, my original plan was to not even export
winsortedon a non-windows machine. But, after I posted my plan I realized a better solution was to instead name the functionos_sorted(or something similar) and have it behave similar to your thought, where it sorts according to how the OS’s file manager would sort.