Created
February 13, 2014 01:26
-
-
Save sgraessle/8968031 to your computer and use it in GitHub Desktop.
This comparison code seems correct, but resulting matches object remains unsorted.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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