Checking order of array objects

I have 4 objects in an array, each object is assigned a random number between 1 and 10. How should I go about checking if these objects are all the same, three of the same, etc. or if they are in order, for instance, objects with int values 7,5,6,4 would be considered in order?
[278 byte] By [spidey6] at [2007-11-20 10:32:01]
# 1 Re: Checking order of array objects
How about a Hand class with a method to determine each type of set, e.g., internal static class Hand
{
internal static bool IsInOrder(List<int> cards)
{
cards.Sort();
bool isInOrder = true;
for (int i = 0; i < cards.Count - 1; i++)
{
isInOrder = isInOrder && cards[i + 1].Equals(cards[i] + 1);
if (!isInOrder)
break;
}
return isInOrder;
}
} and so on and so forth. . .
trenches at 2007-11-9 11:35:24 >
# 2 Re: Checking order of array objects
Easiest way is creating an array of size 10 (0 representing 1, 1 representing 2, etc), and just go through the entire list of objects, adding one to the current value of the newly created array.

e.g. if the first number is 5, add one to array[4].
Homogenn at 2007-11-9 11:36:35 >
# 3 Re: Checking order of array objects
Come to think of it, the Hand class probably should be a non-static class and have the boolean analyzer methods (e.g., IsInOrder, etc.) be non-static as well, so, each hand would know it's own value and may be compared with other hands by a coordinator object
trenches at 2007-11-9 11:37:35 >