Skip to content

Correctly sort experimental compiler versions available in playground #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions src/Playground.res
Original file line number Diff line number Diff line change
Expand Up @@ -910,28 +910,30 @@ module Settings = {
{switch experimentalVersions {
| [] => React.null
| experimentalVersions =>
let versionByOrder = experimentalVersions->Belt.SortArray.stableSortBy((a, b) => {
let cmp = ({Semver.major: major, minor, patch, preRelease}) => {
let preRelease = switch preRelease {
| Some(preRelease) =>
switch preRelease {
| Dev(id) => 0 + id
| Alpha(id) => 10 + id
| Beta(id) => 20 + id
| Rc(id) => 30 + id
let versionByOrder = experimentalVersions->Array.toSorted((b, a) => {
if a.major != b.major {
a.major - b.major
} else if a.minor != b.minor {
a.minor - b.minor
} else if a.patch != b.patch {
a.patch - b.patch
} else {
switch (a.preRelease, b.preRelease)->Option.all2 {
| Some((prereleaseA, prereleaseB)) =>
switch (prereleaseA, prereleaseB) {
| (Rc(rcA), Rc(rcB)) => rcA - rcB
| (Rc(rcA), _) => rcA
| (Beta(betaA), Beta(betaB)) => betaA - betaB
| (Beta(betaA), _) => betaA
| (Alpha(alphaA), Alpha(alphaB)) => alphaA - alphaB
| (Alpha(alphaA), _) => alphaA
| (Dev(devA), Dev(devB)) => devA - devB
| (Dev(devA), _) => devA
}

| None => 0
}
let number =
[major, minor, patch]
->Array.map(v => v->Int.toString)
->Array.join("")
->Int.fromString
->Option.getOr(0)

number + preRelease
}
cmp(b) - cmp(a)
}->Float.fromInt
})
<>
<VersionSelect.SectionHeader value=Constants.dropdownLabelNext />
Expand Down