Click here to Skip to main content
15,898,538 members
Home / Discussions / C#
   

C#

 
QuestionContext Menu with TextBox Filter Pin
doubleas23806-Sep-07 9:58
doubleas23806-Sep-07 9:58 
Questionpopups from webbrowser control Pin
Opa Knack6-Sep-07 9:54
Opa Knack6-Sep-07 9:54 
AnswerRe: popups from webbrowser control Pin
Spacix One6-Sep-07 10:47
Spacix One6-Sep-07 10:47 
QuestionComparing an Image Pin
Gareth H6-Sep-07 8:38
Gareth H6-Sep-07 8:38 
AnswerRe: Comparing an Image Pin
Rick van Woudenberg6-Sep-07 8:57
Rick van Woudenberg6-Sep-07 8:57 
AnswerRe: Comparing an Image Pin
Luc Pattyn6-Sep-07 9:03
sitebuilderLuc Pattyn6-Sep-07 9:03 
AnswerRe: Comparing an Image Pin
Judah Gabriel Himango6-Sep-07 9:05
sponsorJudah Gabriel Himango6-Sep-07 9:05 
QuestionSorting Multiple Properties Pin
DaveyM696-Sep-07 7:45
professionalDaveyM696-Sep-07 7:45 
I've googled and can't find any solutions that work.

I have a class called People that has two public properties of type string - Firstname and Surname.

I have a second class PeopleCollection : ArrayList that is an ArrayList of People objects.

Using the IComparable interface and CompareTo methods on the People class I can successfully sort by either property by specifying .Firstname or .Surname in the CompareTo method.

What I need to be able to do is sort on both fields so if the PeopleCollection instance held this data:

item[0].Firstname = "Dave" | item[0].Surname = "Smith"
item[1].Firstname = "Dave" | item[1].Surname = "Jones"
item[2].Firstname = "Andrew" | item[2].Surname = "Jones"
item[3].Firstname = "Andrew" | item[3].Surname = "Zzz"

after sorting it would be:

item[0].Firstname = "Andrew" | item[0].Surname = "Jones"
item[1].Firstname = "Andrew" | item[1].Surname = "Zzz"
item[2].Firstname = "Dave" | item[2].Surname = "Jones"
item[3].Firstname = "Dave" | item[3].Surname = "Smith"

Both columns sorted with field1 (Firstname) having priority and field2 being 'subsorted'.

I'm sure this is posible using IComparer but I just can't figure it out!

Dave
AnswerRe: Sorting Multiple Properties [modified] Pin
Luc Pattyn6-Sep-07 7:51
sitebuilderLuc Pattyn6-Sep-07 7:51 
GeneralRe: Sorting Multiple Properties Pin
DaveyM696-Sep-07 8:05
professionalDaveyM696-Sep-07 8:05 
GeneralRe: Sorting Multiple Properties Pin
TJoe6-Sep-07 8:16
TJoe6-Sep-07 8:16 
GeneralRe: Sorting Multiple Properties Pin
Luc Pattyn6-Sep-07 8:17
sitebuilderLuc Pattyn6-Sep-07 8:17 
GeneralRe: Sorting Multiple Properties Pin
DaveyM696-Sep-07 8:25
professionalDaveyM696-Sep-07 8:25 
GeneralRe: Sorting Multiple Properties Pin
Luc Pattyn6-Sep-07 8:32
sitebuilderLuc Pattyn6-Sep-07 8:32 
Questionclasses.. Pin
rcwoods6-Sep-07 6:50
rcwoods6-Sep-07 6:50 
AnswerRe: classes.. Pin
Colin Angus Mackay6-Sep-07 6:58
Colin Angus Mackay6-Sep-07 6:58 
GeneralRe: classes.. [modified] Pin
Jason Hanford-Smith6-Sep-07 7:21
Jason Hanford-Smith6-Sep-07 7:21 
GeneralRe: classes.. Pin
Colin Angus Mackay6-Sep-07 9:34
Colin Angus Mackay6-Sep-07 9:34 
GeneralRe: classes.. Pin
Jason Hanford-Smith6-Sep-07 9:37
Jason Hanford-Smith6-Sep-07 9:37 
GeneralRe: classes.. Pin
Larantz6-Sep-07 10:03
Larantz6-Sep-07 10:03 
GeneralRe: classes.. Pin
Colin Angus Mackay6-Sep-07 10:18
Colin Angus Mackay6-Sep-07 10:18 
GeneralRe: classes.. Pin
Larantz6-Sep-07 10:21
Larantz6-Sep-07 10:21 
GeneralRe: classes.. Pin
Colin Angus Mackay6-Sep-07 11:12
Colin Angus Mackay6-Sep-07 11:12 
GeneralRe: classes.. Pin
Colin Angus Mackay6-Sep-07 13:33
Colin Angus Mackay6-Sep-07 13:33 
GeneralRe: classes.. Pin
martin_hughes6-Sep-07 7:47
martin_hughes6-Sep-07 7:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.