ForNeVeR / ForNeVeR/TruePath

Provide guarantees about portable path ordering

Open
#130 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
C#
Stars
104
Forks
15
Avg merge
9m
Merged PRs (30d)
2

Description

In other ecosystems (e.g. Java), I was once surprised by the following behavior.

Say you have a list of relative paths (legally distinguishable on multiple operating systems, i.e. they don't have case conflicts and mix-ups), and you sort them.

In Java, there's no guarantee you'll have the same order on all operating systems, because `/` and `\` have different sort order, and even if you have the same path letters, you'll have different order — say, items `["a/a", "a-a", "a.a"]` vs `["a-a", "a.a", @"a\a"]` might be sorted differently.

A particular problem I've had with this:
```jshell
> listOf(
java.nio.file.Path.of("commons"),
java.nio.file.Path.of("com/x")
).sortedBy { it }
// => [commons, com\x]

> listOf(
"commons",
"com/x"
).sortedBy { it }
// => [com/x, commons]
```

TruePath should guarantee the same ordering for items involving directory separators (i.e. the directory separator should have the same ordering on all the operating systems), document this and cover by tests, of course.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.