# what is natural ordering???

Printable View

• 02-24-2010, 09:41 AM
blueduiker
what is natural ordering???
I was up the sort method of the array class for my school project and it says that the sort class orders the objects in the natural ordering. What does this mean?

static void sort(Object[] a)
Sorts the specified array of objects into ascending order, according to the natural ordering of its elements.
• 02-24-2010, 11:51 AM
JosAH
Quote:

Originally Posted by blueduiker
I was up the sort method of the array class for my school project and it says that the sort class orders the objects in the natural ordering. What does this mean?

static void sort(Object[] a)
Sorts the specified array of objects into ascending order, according to the natural ordering of its elements.

The natural ordering of two objects a and b is the outcome of a.compareTo(b), i.e. what those objects themselves think which one is smaller, greater or equal to the other object. Normally a.compareTo(a) == 0 and if a.compareTo(b) <> 0 then b.compareTo(a) >< 0. The entire thing melts away when you think of integer numbers, e.g. 3 < 4, so 4 > 3 and 3 == 3

kind regards,

Jos