There is a class
public class Camera
{
...
public bool live;
...
}
This is the sorting class
public class CameraSortByLive : IComparer<Camera>
{
private bool asc;
public CameraSortByLive(bool a)
{
this.asc = a;
}
public int Compare(Camera x, Camera y)
{
if (x.live != y.live)
return asc ? 0 : 1;
else
return asc ? 1 : 0;
}
}
This is how I use it:
List<Camera> CameraList = new List<Camera>();
CameraList.Sort(new CameraSortByLive(sortAsc));
Now, I beside live
member I have other members int
, string
type. With those types I have similar sorting class implementing IComparer
. There is no problem with them. The only problem with this live
member. It simply doesn't sort. I expect it to go either on top of list or bottom, but it goes somewhere in the middle. What am I missing?