Click here to Skip to main content
15,914,014 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Sorting a list with class for complex types Pin
Harold_Wishes10-Jul-06 10:49
Harold_Wishes10-Jul-06 10:49 
GeneralRe: Sorting a list with class for complex types Pin
earl10-Jul-06 11:14
earl10-Jul-06 11:14 
GeneralRe: Sorting a list with class for complex types [modified] Pin
Harold_Wishes10-Jul-06 15:07
Harold_Wishes10-Jul-06 15:07 
GeneralRe: Sorting a list with class for complex types Pin
earl11-Jul-06 4:27
earl11-Jul-06 4:27 
AnswerRe: Sorting a list with class for complex types [modified] Pin
Stephen Hewitt10-Jul-06 14:45
Stephen Hewitt10-Jul-06 14:45 
GeneralRe: Sorting a list with class for complex types Pin
Harold_Wishes10-Jul-06 15:00
Harold_Wishes10-Jul-06 15:00 
GeneralRe: Sorting a list with class for complex types Pin
Stephen Hewitt10-Jul-06 15:05
Stephen Hewitt10-Jul-06 15:05 
GeneralRe: Sorting a list with class for complex types [modified] Pin
Harold_Wishes10-Jul-06 22:38
Harold_Wishes10-Jul-06 22:38 
Thanks! This really helps because my goal is to actually compare the string length of the Sequence variable and assign that value to int Number as I have it defined below:

struct data                                             //
{    
     int Number;
     string Length;                   
     string Sequence;                                               
     string N_Terminal;                                             
     string C_Terminal;
friend bool operator<(const data &L, const data &R)    
	{             
	   return L.number > R.number;    
	}

};


Then I invoke the sort after the list has been populated with items.

g_DataList.sort();


You will notice I overloaded the > operator instead of the < operator since I need the longest strings to appear first.

The thing I do not quite get is how the compiler knows what const data &L and const data &R are when they are passed by reference in the friend function. I'm not making the connection between the comparison and the sort function? Perhaps I do not understand the sorting algorithym. I confess my lack of programming experience even though I have the program working like a champ at this stage.

Regards,
HRW. Smile | :)

-- modified at 4:40 Tuesday 11th July, 2006
GeneralRe: Sorting a list with class for complex types Pin
Stephen Hewitt11-Jul-06 1:06
Stephen Hewitt11-Jul-06 1:06 
QuestionRTI - related (Zac Howland) can help [modified] Pin
Jay0310-Jul-06 4:43
Jay0310-Jul-06 4:43 
AnswerRe: RTI - related (Zac Howland) can help Pin
Zac Howland10-Jul-06 5:01
Zac Howland10-Jul-06 5:01 
GeneralRe: RTI - related (Zac Howland) can help Pin
Jay0310-Jul-06 5:16
Jay0310-Jul-06 5:16 
GeneralRe: RTI - related (Zac Howland) can help Pin
Jay0310-Jul-06 6:33
Jay0310-Jul-06 6:33 
GeneralRe: RTI - related (Zac Howland) can help Pin
Zac Howland10-Jul-06 6:54
Zac Howland10-Jul-06 6:54 
GeneralRe: RTI - related (Zac Howland) can help Pin
Jun Du10-Jul-06 7:20
Jun Du10-Jul-06 7:20 
AnswerRe: RTI - related (Zac Howland) can help Pin
earl10-Jul-06 7:24
earl10-Jul-06 7:24 
QuestionDeleting desktop shortcut while not administrator [modified] Pin
clemb10-Jul-06 4:04
clemb10-Jul-06 4:04 
AnswerRe: Deleting desktop shortcut while not administrator Pin
clemb21-Jul-06 4:51
clemb21-Jul-06 4:51 
QuestionGetting the Parent Window Handle Pin
HakunaMatada10-Jul-06 3:53
HakunaMatada10-Jul-06 3:53 
AnswerRe: Getting the Parent Window Handle Pin
Sarath C10-Jul-06 4:15
Sarath C10-Jul-06 4:15 
GeneralRe: Getting the Parent Window Handle Pin
HakunaMatada10-Jul-06 17:20
HakunaMatada10-Jul-06 17:20 
AnswerRe: Getting the Parent Window Handle Pin
Abhi Lahare10-Jul-06 4:15
Abhi Lahare10-Jul-06 4:15 
AnswerRe: Getting the Parent Window Handle Pin
FarPointer10-Jul-06 4:18
FarPointer10-Jul-06 4:18 
AnswerRe: Getting the Parent Window Handle Pin
ThatsAlok10-Jul-06 19:20
ThatsAlok10-Jul-06 19:20 
Questionlist control Pin
jokefake10-Jul-06 3:49
jokefake10-Jul-06 3:49 

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.