Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting and searching in STL 1

Status
Not open for further replies.

Diksi

Programmer
Aug 5, 2002
5
GR
Suppose we have a structure or class with data member double x. Then we put an object to a list STL container, something like that:

container.push_back(object). Now how can we sort the container by value x and how can we find an object where the key equal x ?
 
Sorting

sort (container.begin(), container.end (), greater)

Finding

container::iterator x = find(container.begin(), container.end (), value);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top