Properly Compare True and False Order in Sourcekit

Comparing "false" > "true" will return 0, which when returned by compare
indicates the two are equal which will result in a non deterministic
ordering of "false" and "true". Using .compare returns a negative number
as expected.
This commit is contained in:
Gwen Mittertreiner
2019-07-10 16:25:16 -07:00
parent 3954a4a57b
commit 518196cde9
2 changed files with 2 additions and 2 deletions

View File

@@ -817,7 +817,7 @@ static int compareLiterals(Item &a_, Item &b_) {
// Sort true before false instead of alphabetically.
if (cast<Result>(a_).value->getLiteralKind() == CodeCompletionLiteralKind::BooleanLiteral)
return a_.name > b_.name;
return b_.name.compare(a_.name);
return 0;
}