Sorting with build versions: Normal version should be larger than build version
Hi again. Semver 2.0.0 states in bullet point 11 that "Build metadata does not figure into precedence". Furthermore it states that "Build metadata SHOULD be ignored when determining version precedence."
However, I think that build versions should be smaller than normal versions, i.e. that 0.1.0-alpha > 0.1.0-alpha+123 > 0.1.0-alpha+122. Maybe you could add a flag to allow factoring in build metadata in the sorting process, Sort::sort($versions, true)
$sorted = Sort::sort(
"0.1.0-alpha",
"0.1.0",
"0.1.0-alpha+SNAPSHOT.1404162053git381bf34",
"0.1.0-alpha+SNAPSHOT.1304162053git381bf34",
"0.1.0-alpha+SNAPSHOT.15",
"0.1.0+SNAPSHOT.15"
);
OUTPUTS:
0.1.0-alpha.0
0.1.0-alpha.0+build..SNAPSHOT.15
0.1.0-alpha.0+build..SNAPSHOT.1304162053git381bf34
0.1.0-alpha.0+build..SNAPSHOT.1404162053git381bf34
0.1.0
0.1.0+build..SNAPSHOT.15
I would expect:
0.1.0-alpha.0+build..SNAPSHOT.1304162053git381bf34
0.1.0-alpha.0+build..SNAPSHOT.1404162053git381bf34
0.1.0-alpha.0+build..SNAPSHOT.15
0.1.0-alpha.0
0.1.0+build..SNAPSHOT.15
0.1.0
To get this straight, the build data itself would then be alphabetically ordered?
Yes, that's what I suggest anyway.
SemVer 2.0 is pretty clear that "Build metadata does not figure into precedence". It also states that pre-release identifiers are ordered alphabetically. This is different from how the library functions at this point, and will have to be adressed.
True. I'm just saying if it's not too much trouble. If it is or you don't want people to rely on it, feel free to close this issue.
I get your point but it is not standards compliant. I will keep the issue open, but if it is introduced it will be separately marked in the API (and non-standard when comparing).