If you're using a comparison delegate, here is how I would do it for
your data format:
Inside the class, make a char[] of the order.
Example: char[] order = new char[] { 'Z', 'B', 'R' };
In the comparison method:
int compareMethod(MyObject one, MyObject two)
{
// if they start with the same letter, just compare them
if (one.TextField[0] == two.TextField[0])
return String.Compare(one.TextField, two.TextField);
/* loop through the order, first object to start with a letter in
order gets moved up in the order */
foreach (char c in order)
{
if (one.TextField[0] == c)
return -1;
if (two.TextField[0] == c)
return 1;
}
//code shouldn't get here if all possible first letters are
provided in the order array
return String.Compare(one.TextField, two.TextField);
}
This should let you define the custom order you need.
Dan Manges
ASP Developer wrote:
Dan,
Thanks for the reply. I need to fulfill one more thing with this type of
sorting. I need to be able to specify which order the letters sort in. For
example,
Z300
B100
R200
Basically the letters are sorted based on some other logic and not
alphabetically. Talk to you soon.