Sorting a vector of nodes based on a struct attribute

OK so I've heard of sorting structs and I've heard of sorting objects based on attributes, but could someone explain how I would sort objects based on a struct attribute?

I have a vector of nodes "nodevector", that I wish to sort from smallest to largest. I want to sort this vector based on the attribute "tm time". I have a function available to sort time, smallTime(time1, time2), which compares two times and returns true if time 1 is smaller than time 2 and returns false otherwise.
http://www.cplusplus.com/reference/algorithm/sort/

1
2
3
std::sort( nodevector.begin(), nodevector.end(),
           [](const node& lhs, const node& rhs)
           { return smallTime(lhs.time,rhs.time); } );
Topic archived. No new replies allowed.