i had created a c# my class list with three fields. that fields also list namely device id, device mode, time. i had sort my class list with respect to to time. time list is sorted successfully but device mode list is not sorted with respect to time list. how can i achieve it. my sample code i given below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PBAttendance.App_Code
{
public class DeviceLogData
{
List<int> deviceID = new List<int> { };
List<int> deviceMode = new List<int> { };
List<DateTime> time = new List<DateTime> { };
public List<int> DeviceID
{
get { return deviceID; }
set { deviceID = value; }
}
public List<int> DeviceMode
{
get { return deviceMode; }
set { deviceMode = value; }
}
public List<DateTime> Time
{
get { return time; }
set { time = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PBAttendance.App_Code
{
public class DeviceLogDataList:List<DeviceLogData>
{
}
}
DeviceLogDataList dvclogDataList = new DeviceLogDataList();
DeviceLogData dvclogData = new DeviceLogData();
dvclogData.DeviceID.Add(1);
dvclogData.DeviceMode.Add(1);
dvclogData.Time.Add(DateTime.ParseExact("10:49", "HH:mm", System.Globalization.CultureInfo.InvariantCulture));
dvclogData.DeviceID.Add(1);
dvclogData.DeviceMode.Add(1);
dvclogData.Time.Add(DateTime.ParseExact("10:49", "HH:mm", System.Globalization.CultureInfo.InvariantCulture));
dvclogData.DeviceID.Add(1);
dvclogData.DeviceMode.Add(2);
dvclogData.Time.Add(DateTime.ParseExact("12:51", "HH:mm", System.Globalization.CultureInfo.InvariantCulture));
dvclogData.DeviceID.Add(1);
dvclogData.DeviceMode.Add(2);
dvclogData.Time.Add(DateTime.ParseExact("09:49", "HH:mm", System.Globalization.CultureInfo.InvariantCulture));
dvclogData.DeviceID.Add(1);
dvclogData.DeviceMode.Add(1);
dvclogData.Time.Add(DateTime.ParseExact("13:49", "HH:mm", System.Globalization.CultureInfo.InvariantCulture));
dvclogDataList.Add(dvclogData);
dvclogDataList[0].Time.Sort();
The time list is sorted to 09:49,10:49,10:49,12:51,13:49 perfectly but the device mode and device id not sorted with respect to time list. how can achieve this. please help me. sorry for my bad English. thanks in advance.