sorting vector storing TIME

Hello all

Could any one please tell me how do I sort a vector of type struct storing "time" (besides few other variables) e-g 13:00:28.91, 12:58:24.81, 12:57:44.18, 13:00:28.86 12:58:32.93 and the result should be 13:00:28.91, 13:00:28.86, 12:58:32.93, 12:58:24.81, 12:57:44.18

Thanks
You do this with std::sort:
http://www.cplusplus.com/reference/algorithm/sort/

You'll have to make sure the class you're using implements operator< or supply a suitable comparison object.
Thanks Athar

That's the part I am confused about. Could you please write to me that test which would sort the times, latest being the first and earliest being the last.
You just have to write sort(vec.begin(),vec.end()); to sort your vector.
The implementation of operator< depends on how your time class looks like.
Thanks Athar :)
Topic archived. No new replies allowed.