Linked list

Aug 9, 2014 at 1:34pm
Hi Everyone,

Can someone explain how to sort a linked list?

Thanks for help.
Aug 9, 2014 at 3:20pm
Can we assume that you know sorting and linked lists?

You can swap values as necessary, just like when sorting other containers.

However, if value copy is expensive, then you could swap by relinking nodes. That would rely on remove and insert list operations.
Aug 9, 2014 at 5:02pm
I know how it works, but the implementation in C++ troubles me.
Ok.
Aug 9, 2014 at 8:01pm
The implementation possibilities depend on the features of the list. On std::list a non-copying swap would use list::splice.
Topic archived. No new replies allowed.