STL list C++ sort and delete :)

struct node{
int num;
int num2;
};
list<node> list;
list<node>::iterator iter;

node temp;
temp.num = 10;
temp.num2 = 20;
list.push_back(temp);

hello guys, can some1 give me an idea how to sort, and how to delete a specific node in this list? list.sort() and list.erase() are not working in this situation.. thanks!!
Why aren't they working? How are you calling them? What results do you get?
````
Last edited on
You aren't calling list::sort in your code
http://www.cplusplus.com/reference/stl/list/sort/


Please use [code][/code] tags
;(( myList.sort() does not work here.. structure inside STL list; .. It would work only if i used int or string.. but this is Flight hehe anyways thanks tho...

I'll use [code] next time, i am new to this forum heheh ^^''
Did you read the reference?
1
2
template <class Compare>
  void sort ( Compare comp );


Parameters

comp
Comparison function that, taking two values of the same type than those contained in the list object, returns true if the first argument goes before the second argument in the specific order (i.e., if the first is less than the second), and false otherwise.
oh ok i got it, thanks
Topic archived. No new replies allowed.