Skip to content

Instantly share code, notes, and snippets.

@sgraessle
Created February 13, 2014 01:26
Show Gist options
  • Save sgraessle/8968031 to your computer and use it in GitHub Desktop.
Save sgraessle/8968031 to your computer and use it in GitHub Desktop.
This comparison code seems correct, but resulting matches object remains unsorted.
GameCenterTurnBasedManager.loadMatchesDidFinishEvent += (List<GKTurnBasedMatch> matches) => {
Logger.Log ("loadMatchesDidFinish: " + Json.GetJsonString(matches));
matches.Sort((x, y) => {
if (x.currentParticipant != null && x.currentParticipant.playerId == GameCenterBinding.playerIdentifier()) return -1;
else if (y.currentParticipant != null && y.currentParticipant.playerId == GameCenterBinding.playerIdentifier()) return 1;
else if (x.status == y.status) return -x.creationDate.CompareTo(y.creationDate);
else if (x.status == GKTurnBasedMatchStatus.Ended) return 1;
else if (y.status == GKTurnBasedMatchStatus.Ended) return -1;
else if (x.status == GKTurnBasedMatchStatus.Matching) return -1;
else if (y.status == GKTurnBasedMatchStatus.Matching) return 1;
else return 0;
});
MatchesLoadedEvent.Raise(this, new MatchesLoadedEventArgs() {Matches = matches});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment