Ell*_*sch 21
字典顺序是按字母顺序排列的.另一种是数字排序.考虑以下值,
1, 10, 2
Run Code Online (Sandbox Code Playgroud)
这些值按字典顺序排列.10以数字顺序出现在2之后,但是以"按字母顺序"顺序排在第2之前.
小智 19
字母顺序是一种特殊的字典顺序。术语词典通常指的是数学规则或排序。例如,这些包括从逻辑上证明排序是可能的。在维基百科上阅读有关词典顺序的更多信息
字母顺序包括在如何处理空格、大写字符、数字和标点符号方面不同的变体。纯粹主义者认为,允许 az 以外的字符使排序不是“字母顺序”,因此它必须属于更大的“词典”类。同样,维基百科有更多细节。
在计算机编程中,一个相关的问题是字典顺序或ascii 代码顺序。在字典顺序中,大写“A”与小写“a”相邻排序。但是,在许多计算机语言中,默认的字符串比较将使用 ascii 代码。对于 ascii,所有大写字母都排在任何小写字母之前,这意味着“Z”将排在“a”之前。这有时称为ASCIIbetical order。
Ham*_*ada 13
This simply means "dictionary order", i.e., the way in which words are ordered in a dictionary. If you were to determine which one of the two words would come before the other in a dictionary, you would compare the words letter by the letter starting from the first position. For example, the word "children" will appear before (and can be considered smaller) than the word "chill" because the first four letters of the two words are the same but the letter at the fifth position in "children" (i.e. d ) comes before (or is smaller than) the letter at the fifth position in "chill" (i.e. l ). Observe that lengthwise, the word "children" is bigger than "chill"但长度不是这里的标准。出于同样的原因,包含12345的数组将出现在包含1235的数组之前。(Deshmukh,OCP Java SE 11 程序员 I 1Z0815 学习指南 2019)
我想添加一个与该术语的编程方面而不是数学方面更相关的答案。
字典顺序并不总是等同于“字典顺序”,至少这个定义在编程领域并不完整,而是指“基于多个标准的排序”。
例如,几乎在所有著名的编程语言中,都有用于对对象集合进行排序的标准工具,现在如果您想基于多个事物对集合进行排序怎么办?例如,假设您想首先根据价格然后根据受欢迎程度对某些商品进行排序。这是词典顺序的一个例子。
例如,在 Java (8+) 中,您可以执行以下操作:
// sorts items from the cheapest AND the most popular ones
// towards the most expensive AND the least popular ones.
Collections.sort(items,
Comparator.comparing(Item::price)
.thenComparing(Item::popularity)
.reversed()
);
Run Code Online (Sandbox Code Playgroud)
Java 文档在解释“thenComaring()”方法时也使用这个术语来指代这种类型的排序:
返回一个字典顺序比较器与另一个比较器。
| 归档时间: |
|
| 查看次数: |
14585 次 |
| 最近记录: |