linux sort命令 算法

2025-05-14 22:40:14
推荐回答(3个)
回答1:

man sort中关于它的描述是
sort - sort lines of text files

所以,它默认是以文本排序的。
但是它又有其它参数
-b, --ignore-leading-blanks
ignore leading blanks
-d, --dictionary-order
consider only blanks and alphanumeric characters
-f, --ignore-case
fold lower case to upper case characters
-g, --general-numeric-sort
compare according to general numerical value
-i, --ignore-nonprinting
consider only printable characters
-M, --month-sort
compare (unknown) < ‘JAN’ < ... < ‘DEC’
-n, --numeric-sort
compare according to string numerical value
-r, --reverse
reverse the result of comparisons
可以忽略前置的空格、或指定顺序字典、或忽略大小写、或以正常的数字形式、或忽略不可打印字符、或以月份(包括英语的月份)、或以字符形式的数字、或以倒序形式排序。

回答2:

按ASCII码值进行排序的

按行进行处理

回答3:

dfc