I have a newbie C++ dilemma. When would it be advantageous to encapsulate a function into a class? And when would it be better to have that function by itself (i.e. not associated with any class)?

For example, think about sorting a list. Would it be better to have the sort function as a member function of the type LIST? Or create the sort function as a separate function from the type LIST? This is just an example. In general, what is the rule of thumb?

Thanks in advance.