Now let’s talk about order. Given a set of objects, there can be numerous criteria, based on which to order them, and which depend on the objects themselves - size, weight, age, alphabetical order etc.

However, as mathematicians we are not interested in the criteria that we can use to order objects, but in the nature of the relationship that defines the order. Of which there can be several types as well.

Mathematically we can represent order as a set of things (e.g. colorful balls) and a binary relation between these things (which we often represent as a bunch of arrows). Not all binary relationships are orders - only ones that fit certain criteria that we are going to examine as we review the different types of order.

Linear order

The most straightforward type of order that you think about is linear order i.e. one in which every object has its place depending on every other object. In this case the ordering criteria is completely deterministic and leaves no room for ambiguity in terms of which element comes before which. For example, ordering the colors by the length of their waves (or by how they appear in the rainbow).

In most programming languages, we can order objects linearly by providing a function which, given two objects, tells us which one of them is “bigger” (comes first) and which one is “smaller”.

[1, 3, 2].sort((a, b) => {
  if (a > b) {
    return true
  } else {
    return false
  }
})

But in order for such a function to really define an order (e.g. give the same output every time, independent of how the objects were shuffled initially), it has to obey several rules.

Incidentally, (or rather not incidentally at all), these rules are nearly equivalent to the mathematical laws that define the criteria of the relationship between elements in an order i.e. those are the rules that define which element can point to which. Let’s review them.

Reflexivity

Let’s get the most boring law out of the way - each object has to be bigger or equal to itself, or a ≤ a (the relationship between elements in an order is commonly denoted as in formulas, but it can also be represented with a simple arrow from first object to the second).

No special reason for this law to be so, except that the “base case” should be covered somehow.

We can formulate it the opposite way too and say that each object should not have the relationship to itself, in which case we would have a relation than resembles bigger than, as opposed to bigger or equal to and a slightly different type of order, sometimes called a strict order.

Transitivity

The second law is maybe the least obvious, (but probably the most essential) - it states that if object a is bigger than object b, it is automatically bigger than all objects that are smaller than object b or a ≤ b and b ≤ c ➞ a ≤ c.

This is the law that to a large extend defines what an order is: if I am better at playing soccer than my grandmother, then I would also be better at it than my grandmother’s friend, whom she beats, otherwise I wouldn’t really be better than her.