TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Zuff
NA
2
0
What's wrong with my sorting?
Aug 5 2008 12:10 AM
Hi all,
I can't really figure out what wrong with my sorting.
private void SortGraph(ABPMBPResult value)
{
if (value == null)
return;
List<BPData> data = value.ToList<BPData>();
data.Sort(delegate(BPData bp1, BPData bp2)
{
return ConvertX(bp1).CompareTo(ConvertX(bp2));
}
);
}
private int ConvertX(BPData value) {
DateTime dt = value.DateTime;
if (dt.Hour >= 0 &&
dt.Hour < 12)
{
return (dt.Hour + 12) * 300 + dt.Minute * 5 + 700;
}
else
{
return (dt.Hour - 12) * 300 + dt.Minute * 5 + 700;
}
}
"All work well" if my (ABPMBPResult value) starts after 12 noon, however, if it starts in the morning, then the sorting is wrong. I presume that my sorting is not really sorting in the ascending order. 12noon, 1pm, .... 12 midnight, 1am .... 6am .... 9, ... 1159am
Thanks and Best Regards,
Zuff
Reply
Answers (
0
)
brand new, looking to learn
Cannot change the DataSet name once the DataSet is mapped to a loaded XML document.