[help] Sorting structures...??

12/09/2012 23:21 Hikarim#1
Well, how can i sort structers according to one element of them??

Code:
      struct PersonalData
        {
               int
                char *FirstName;
                char *LastName;
                char *Birthday;  // in the format of 12/30/1978
                int  id;
        };


        PersonalData PersonOne;

        // Populate PersonOne with data
        PersonOne.FirstName = "John";
        PersonOne.LastName = "Doe";
        PersonOne.Birthday = "12/30/1978";
        PersonOne.id = 5;

        // Populate PersonTwo with data
        PersonTwo.FirstName = "Matt";
        PersonTwo.LastName = "Thompson";
        PersonTwo.Birthday = "15/20/1958";
        PersonTwo.id = 3;
so lets say i'd like to sort them according to the 'id' element of the structures, how do i do it??
12/09/2012 23:39 nkkk#2
you put your structs in a std::list and use list.sort

you should also use std::string (or wstring) instead of char*.
12/20/2012 16:35 +Yazzn#3
[Only registered and activated users can see links. Click Here To Register...]

But rather use std::list.