Q:

Can a self-balancing binary search tree be applied to an object?

I've been studying trees for a few days, and I'm a little confused about how they are sorted.  The basic node is easy enough:
template < typename TYPE >
struct Node {

    TYPE Data;
    Node < TYPE > * Left;
    Node < TYPE > * Right;

};

In terms of sorting, I understand that it is a simple comparison entailing a node's data (lower on the left, higher on the right), and I can see how this would work on integral types (int, double, float, char).  What I'm confused about is how this is done with user defined types and objects.  What exactly is/should be compared?  Is this simply a case by case answer or is there a general method that can be used?
Any information that could help clear this up in my head would be greatly appreciated.

A:

I think there's not a true answer to this question.

What exactly is/should be compared?

It depends on the data type! If you have a string you may want to sort them in alphabetical order. If the string represents a role you may want to sort by importance. What if a color? You may sort by hue or by brightness. There is not a universal answer.
If something is not comparable at all (or a comparison doesn't have sense, imagine you're comparing objects that represent clothes) maybe you shouldn't use a sorted tree!

