Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2009, 10:16 AM
Authorized User
 
Join Date: Jun 2008
Posts: 75
Thanks: 15
Thanked 0 Times in 0 Posts
Default Sorting objects in a Collection or List

Happy New Year to All my fellow Programmers,

I have a quick question. I was wondering does .Net provide a Collection or List Class that has a SORT feature built in? I appreciate any answers or referals to articles that can help me.

Thanks In Advance and may this coming year bring All Peace, Prosperity, and Happiness.
 
Old January 7th, 2009, 10:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You can sort the list class you questioned in the last post.
Check out this link.
http://dotnetslackers.com/Community/...0_T_3E00_.aspx
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
 
Old January 7th, 2009, 10:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Yes, the List<T> class has a Sort method that you need to pass a class that can handle the sorting for you (or at least, determine which of two objects is "greater" than the other.

For more info:

http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=428

You may also want to take a look at part 4 of my article series that starts here:

http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=476

Part 4 will be posted in a few weeks, but you can download the full source now...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 7th, 2009, 12:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. I think that OP is looking for the sortedlist class. It sorts all objects automatic.

maybe this link is what you need?
http://msdn.microsoft.com/en-us/library/system.collections.sortedlist(VS.80).aspx
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting GridView with a Collection as DataSource+ danielpilon C# 7 June 10th, 2008 04:20 PM
Sorting a list by the third element Devlin C# 2008 aka C# 3.0 5 March 12th, 2008 10:47 AM
List not sorting, round two Devlin C# 2005 1 March 11th, 2008 02:54 PM
(Collection) appears in the list box Tracey BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 April 30th, 2007 09:53 AM
Data Binding to a Collection of Objects jaucourt VB.NET 2002/2003 Basics 1 February 12th, 2004 03:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.