473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Generic List Sort Issue with Same data?

I am creating a list (myEmployeeList) as follows

myEmployeeList.Add(new Employee(12, "Anand", 25));
myEmployeeList.Add(new Employee(12, "Viral", 26));
myEmployeeList.Add(new Employee(12, "Meet", 20));
myEmployeeList.Add(new Employee(12, "Rahul", 28));

Now when i do sort with respect to ID column

myEmployeeList.Sort(Employee.IDComparison);

The resultant sorted list will be like
12 Meet 20
12 Rahul 28
12 Anand 25
12 Viral 26

Note : The list order is changing earlier it was (Anand,VIral,Meet,Rahul) now (Meet,Rahul,Anand,Viral)
Ideally it should not sort as the ID column is same (12) in all rows.
How can i avoide Sorting when the column data is same in all rows?
Please Respond
Thanks in Advance
Jan 12 '11 #1
1 1389
This link will help you understand the behavior of "Sort" method

http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx
Jan 14 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: majm | last post by:
I'm trying to implement strongly typed lists in the 2.0 framework. I'm using VS2005 beta 2. So far, System.Collections.Generic.List appears to be the ideal solution. However, the...
3
by: ASP Developer | last post by:
I have a generic list of objects. These objects have a text field that contains a letter for the first character and numbers for the next three. For example, "A001". I need to sort these by...
4
by: rsa_net_newbie | last post by:
Hi there, I have a Managed C++ object (in a DLL) which has a method that is defined like ... Generic::List<String^>^ buildList(String^ inParm) Now, when I compile it, I get "warning C4172:...
3
by: Peter Olcott | last post by:
How does not specify the sort criteria for Generic.List ?? The way that this is done in C++ STL is to implement operator<(), how is this done in C# and DotNet for Generic.List ???
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
0
by: Amar | last post by:
Hi, I have a generic list with a some objects of a particular class in it. I have implemented a IComparer for the the class and pass it to the List. The list.sort method works fine when the value...
2
by: shapper | last post by:
Hello, I have an Enum and a Generic.List(Of Enum) 1 Public Enum Mode 2 Count 3 Day 4 Month 5 End Enum
9
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a generic list that is populated with a structure. I would like to be able to sort on values in the structure. I have public struct mergoutstruct { public Int32 projectnumber; public...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a generic list populated by a structure and sorts the contents of the list based on the day and project # that is part of the structure. I would like to modify it to also sort on the...
0
by: Buky | last post by:
So, Let's say that I have an class with properies like Name, LastName & ID. I put them into List(of myClass) and I would like to search through that List based on my search criteria (Name & Id for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.