Skip to content

Commit 787b92d

Browse files
fix: suggestionList ordering is deterministic
1 parent 79c7ca0 commit 787b92d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/GraphQL/SwiftUtilities/SuggestionList.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ func suggestionList(
2020
}
2121
return optionsByDistance.keys.sorted {
2222
// Values are guaranteed non-nil since the keys come from the object itself
23-
optionsByDistance[$0]! - optionsByDistance[$1]! != 0
23+
let distanceDiff = optionsByDistance[$0]! - optionsByDistance[$1]!
24+
if distanceDiff != 0 {
25+
return distanceDiff < 0
26+
} else {
27+
return $0.lexicographicallyPrecedes($1)
28+
}
2429
}
2530
}
2631

0 commit comments

Comments
 (0)