当我们谈论排序时,自然排序是什么?

当我们谈论排序时,自然排序是什么?

问题描述:

自然排序是什么意思.假设我有一个Employee对象,其名称,年龄和加入日期按什么是自然顺序排序?

What is meant by natural ordering . Suppose I have an Employee object with name , age and date of joining , sorting by what is natural ordering ?

自然排序是一种字母数字排序,对人类而言似乎很自然.

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.

在我看来,订购Employee首先要使用自然排序按姓名排序,然后是年龄,最后是加入日期.

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.