Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • @StéphaneChazelas A bit hairy, but ok... Commented Sep 23, 2017 at 19:39
  • Note that arguably, it computes the wrong basename for paths like /some/dir/. Commented Sep 23, 2017 at 19:50
  • @StéphaneChazelas Yes, but the OP specifically said he had paths of files, so I'll just assume that there is a proper basename at the end of the path. Commented Sep 23, 2017 at 19:55
  • Note that in a typical GNU non-C locale, a/x.c++ b/x.c-- c/x.c++ would be sorted in that order even though - sorts before + because -, + and /'s primary weight is IGNORE (so comparing x.c++/a/x.c++ against x.c--/b/x.c++ first compares xcaxc against xcbxc, and only in case of ties would the other weights (where - comes before +) would be considered. Commented Sep 24, 2017 at 7:19
  • That could be worked around by joining on /x/ instead of /, but that wouldn't address the case where in the C locale on ASCII based systems, a/foo would sort after a/foo.txt for instance because / sorts after .. Commented Sep 24, 2017 at 8:21