In article <0a****************************@phx.gbl>,
ni**@winger.at
says...
I have Objects in my ArrayList
These Objects contain a String called "Name".
And i want that ArrayList to sort
it's objects using the Name element of each
object and not something else of the object ?!?
Here's how I did it (I also have a pretty good typesafe ArrayList for
this class courtesy of
10*@100.com, if you'd like to see it):
public class QRow : IComparable, ICloneable
{
public int qId;
public int testId;
public string objective;
public int placement;
////////////////////////////////////////////////////////////
public QRow()
{
qId = 0;
testId = 0;
objective = "";
placement = -1;
}
////////////////////////////////////////////////////////////
public QRow(QRow other)
{
this.qId = other.qId;
this.testId = other.testId;
this.objective = other.objective;
this.placement = other.placement;
}
#region IComparable Members
public int CompareTo(object rhs)
{
QRow r = (QRow) rhs;
return this.placement.CompareTo(r.placement);
}
#endregion
#region ICloneable Members
public object Clone()
{
return new QRow(this);
}
#endregion
}