a358
March 26th, 2009, 06:37 PM
Hi,
I have the following function in a program that I am modifying. I know that its sorting a collection of Card classes by the Rank property.
But I don't understand the code, why are they multiplying the rank value by 100?
private class RankComparer : IComparer<Card> {
public int Compare(Card x, Card y) {
return (100 * (int)x.Rank + (int)x.Suit).CompareTo(100 * (int)y.Rank + (int)y.Suit);
}
}
I have the following function in a program that I am modifying. I know that its sorting a collection of Card classes by the Rank property.
But I don't understand the code, why are they multiplying the rank value by 100?
private class RankComparer : IComparer<Card> {
public int Compare(Card x, Card y) {
return (100 * (int)x.Rank + (int)x.Suit).CompareTo(100 * (int)y.Rank + (int)y.Suit);
}
}