亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 6148 | 回復: 13
打印 上一主題 下一主題

sort排序-科學表達式無法正確排序 [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2012-04-21 12:56 |只看該作者 |倒序瀏覽
大家好。
我想請問大家在用shell的sort命令進行排序的時候,用-n選項表示是對數(shù)值排序。但是對于以科學技術表示的無法排序,該如何處理?謝謝。
示例如下:
-----------------------------------------test----------------------------
郝蕾        0.006323855243722304        4.0        8.0        137.0
郭亮        4.615952732644018E-5        1.0        2.0        1.0
郭伯雄        1.8463810930576072E-4        1.0        1.0        2.0
---------------------------------------------------------------------
我對以上用命令:sort -n --k=2,2 test -r -o rsult,進行排序,得到的結(jié)果如下:

-----------------------------------------result----------------------------
郭亮        4.615952732644018E-5        1.0        2.0        1.0
郭伯雄        1.8463810930576072E-4        1.0        1.0        2.0
郝蕾        0.006323855243722304        4.0        8.0        137.0
---------------------------------------------------------------------
正確結(jié)果該為:
-----------------------------------------right----------------------------
郝蕾        0.006323855243722304        4.0        8.0        137.0
郭伯雄        1.8463810930576072E-4        1.0        1.0        2.0
郭亮        4.615952732644018E-5        1.0        2.0        1.0
---------------------------------------------------------------------

論壇徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亞冠之浦和紅鉆
日期:2015-06-23 19:10:532015亞冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16賽季CBA聯(lián)賽之山東
日期:2016-01-31 18:25:0515-16賽季CBA聯(lián)賽之四川
日期:2016-02-16 16:08:30程序設計版塊每日發(fā)帖之星
日期:2016-06-29 06:20:002017金雞報曉
日期:2017-01-10 15:19:5615-16賽季CBA聯(lián)賽之佛山
日期:2017-02-27 20:41:19
2 [報告]
發(fā)表于 2012-04-21 13:28 |只看該作者
試試-g,如果版本支持的話

論壇徽章:
0
3 [報告]
發(fā)表于 2012-04-21 13:34 |只看該作者
回復 2# waker


    正確了。謝謝。
    man 說的-g表示general-numeric-sort,這是什么意思,包括一些別的情況么?謝謝。

論壇徽章:
0
4 [報告]
發(fā)表于 2012-04-21 15:14 |只看該作者
Zigengdi 發(fā)表于 2012-04-21 13:34
回復 2# waker


字面理解:視為一般數(shù)字

不知是否正確

論壇徽章:
0
5 [報告]
發(fā)表于 2012-04-21 20:14 |只看該作者
-n 是數(shù)值字符排序
-g 是根據(jù)數(shù)值的大小排序
說錯了 請輕拍 呵呵

論壇徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年紀念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役紀念章
日期:2022-04-24 14:33:24
6 [報告]
發(fā)表于 2012-04-21 20:17 |只看該作者
回復 5# g_programming


    數(shù)值字符排序排序是什么意思,給個例子吧。

論壇徽章:
0
7 [報告]
發(fā)表于 2012-04-21 21:27 |只看該作者
回復 6# Shell_HAT


    我是按照手冊上面翻譯的 呵呵 數(shù)值字符排序就是指的是0-9這個10個字符
(1)按照數(shù)值字符排序
郝蕾        0.006323855243722304        
郭亮        4.615952732644018E-5      
郭伯雄      1.8463810930576072E-4      
第二列的數(shù)值字符為0,4,1,所以排序出來為   
郭亮        4.615952732644018E-5      
郭伯雄      1.8463810930576072E-4
郝蕾        0.006323855243722304   
(2)按照數(shù)值的大小排序 是指的是字符串轉(zhuǎn)換為數(shù)值的大小
所以為
郝蕾        0.006323855243722304     
郭伯雄      1.8463810930576072E-4   
郭亮        4.615952732644018E-5      

不知道說對沒?

論壇徽章:
0
8 [報告]
發(fā)表于 2012-04-22 22:27 |只看該作者
回復 5# g_programming

牛人啊  拜大神
   

論壇徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亞冠之浦和紅鉆
日期:2015-06-23 19:10:532015亞冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16賽季CBA聯(lián)賽之山東
日期:2016-01-31 18:25:0515-16賽季CBA聯(lián)賽之四川
日期:2016-02-16 16:08:30程序設計版塊每日發(fā)帖之星
日期:2016-06-29 06:20:002017金雞報曉
日期:2017-01-10 15:19:5615-16賽季CBA聯(lián)賽之佛山
日期:2017-02-27 20:41:19
9 [報告]
發(fā)表于 2012-04-23 08:53 |只看該作者
本帖最后由 waker 于 2012-04-23 08:54 編輯

info sort 有詳解

  1. `-g'
  2. `--general-numeric-sort'
  3. `--sort=general-numeric'
  4.      Sort numerically, using the standard C function `strtod' to convert
  5.      a prefix of each line to a double-precision floating point number.
  6.      This allows floating point numbers to be specified in scientific
  7.      notation, like `1.0e-34' and `10e100'.  The `LC_NUMERIC' locale
  8.      determines the decimal-point character.  Do not report overflow,
  9.      underflow, or conversion errors.  Use the following collating
  10.      sequence:

  11.         * Lines that do not start with numbers (all considered to be
  12.           equal).

  13.         * NaNs ("Not a Number" values, in IEEE floating point
  14.           arithmetic) in a consistent but machine-dependent order.

  15.         * Minus infinity.

  16.         * Finite numbers in ascending numeric order (with -0 and +0
  17.           equal).


  18.         * Plus infinity.

  19.      Use this option only if there is no alternative; it is much slower
  20.      than `--numeric-sort' (`-n') and it can lose information when
  21.      converting to floating point.


復制代碼

  1. `-n'
  2. `--numeric-sort'
  3. `--sort=numeric'
  4.      Sort numerically.  The number begins each line and consists of
  5.      optional blanks, an optional `-' sign, and zero or more digits
  6.      possibly separated by thousands separators, optionally followed by
  7.      a decimal-point character and zero or more digits.  An empty
  8.      number is treated as `0'.  The `LC_NUMERIC' locale specifies the
  9.      decimal-point character and thousands separator.  By default a
  10.      blank is a space or a tab, but the `LC_CTYPE' locale can change
  11.      this.

  12.      Comparison is exact; there is no rounding error.

  13.      Neither a leading `+' nor exponential notation is recognized.  To
  14.      compare such strings numerically, use the `--general-numeric-sort'
  15.      (`-g') option.

復制代碼

論壇徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亞冠之浦和紅鉆
日期:2015-06-23 19:10:532015亞冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16賽季CBA聯(lián)賽之山東
日期:2016-01-31 18:25:0515-16賽季CBA聯(lián)賽之四川
日期:2016-02-16 16:08:30程序設計版塊每日發(fā)帖之星
日期:2016-06-29 06:20:002017金雞報曉
日期:2017-01-10 15:19:5615-16賽季CBA聯(lián)賽之佛山
日期:2017-02-27 20:41:19
10 [報告]
發(fā)表于 2012-04-23 08:57 |只看該作者
關于6#的提法俺的理解:
如果使用-n選項
sort認為1.8463810930576072E-4根本就不是一個合法數(shù)值,只能按缺省的字串排序方法排序
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP