Open lucatrv opened 1 year ago
I'm fine with this, but only if it doesn't introduce new dependencies. And it should be Unicode aware. So hopefully this can be done with APIs in std, although it may involve allocs. I'm personally fine with that.
As an additional note, for performance reasons maybe it would be preferable to use the
sort_unstable
/sort_unstable_by
/sort_unstable_by_key
methods instead of thesort
/sort_by
/sort_by_key
methods.
I think this is fine.
@BurntSushi, thanks for your feedback, I issued PR #173 and #174, not sure why they did not pass CI tests...
Considering a directory
./test
with entriesa
B
c
D
, the commandls test
prints entries in alphabetical order regardless of case.Instead the following code:
prints entries in the following order:
The reason is clear and is due to the
sort
method, however it took me some time to detect this behavior in a larger code where I was relying on actual alphabetical sorting.Although one can easily implement case-insensitive alphabetical order using the lower level
sort_by
orsort_by_key
methods, the existence of an additionalsort_by_file_name_case_insensitive
method would better clarify the two actual behaviors, and would probably be of wider use thansort_by_file_name
.If you agree I can issue a PR.
As an additional note, for performance reasons maybe it would be preferable to use the
sort_unstable
/sort_unstable_by
/sort_unstable_by_key
methods instead of thesort
/sort_by
/sort_by_key
methods.