I want to put custom classes into a generic class.
Here’s my class called A.
public class AA
{
float m_fTime;
int m_nI;
int m_nYou;
public AA(float f, int n, int n2)
{
m_fTime = f; m_nI = n; m_nYou = n2;
}
public void print()
{
print(m_fTime);
}
}
And TestClass
public class SortTest
{
List<AA> mylist = new List<AA>();
public SortTest()
{
AA a1 = new AA(1.0f, 2, 3);
mylist.Add(a1);
a1 = new AA(3.0f, 1, 5);
mylist.Add(a1);
a1 = new AA(2.0f, 5, 2);
mylist.Add(a1);
for (int i = 0; i < mylist.Count; i++)
mylist[i].print();
}
}
The result will be “1.0f, 3.0f, 2.0f”.
However, I want to order them in the list by ascending with “m_fTime” variable.
like “1.0f, 2.0f, 3.0f …”
Is there any generic class to achieve it like std::set in c/c++?
Help me out. Thanks.