what is natural ordering when we talk about sorting?

Natural ordering is a kind of alphanumerical sort which seems natural to humans.

In a classical alphanumerical sort we will have something like :

1 10 11 12 2 20 21 3 4 5 6 7

If you're using Natural ordering, it will be :

1 2 3 4 5 6 7 10 11 12 20 21

Depending on the language, natural ordering sometimes ignore Capital letters and accentuated one (ie all accentuated letters are treated like their non-accentuated counterpart).

Many languages have a function to order a String naturally. However, an Employee is too "high level" for the language, you must decide what it means for you to order them naturally and create the according function.

In my point of view, ordering Employee will start by ordering them by name using a natural sort, then age and finally date of joining.

According to statistics there are two types of categorical variables. Variables having categories without a numerical ordering (nominal) and those which do have ordered categories (ordinal). The example of an Employee's name, age and date of joining is actually considered a nominal variable so there can be no sorting by natural ordering. Natural ordering could exist for example in age had you categorized it in levels of child, teenager, adult, in which one can observe an ascending type of sorting.


For strings containing numbers it means 1,2,3,4,5,6,7,8,9,10,11 instead of 1,10,11,2,3,4,5,6,7,8,9