免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: yinyuemi

[文本处理] 中秋送题目^_^ [复制链接]

论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
发表于 2014-09-10 15:11 |显示全部楼层
本帖最后由 jason680 于 2014-09-10 15:33 编辑

回复 80# blackold

楼主需求:

A B C D 四列数据,要求排序得到如下,
排A列从小到大
排B列,...
   

是要重排啊...

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
发表于 2014-09-10 15:21 |显示全部楼层
回复 81# jason680


    未必是这样。

46 楼是另一种理解。

论坛徽章:
2
白羊座
日期:2013-11-18 19:52:42辰龙
日期:2014-09-07 07:46:06
发表于 2014-09-10 15:22 |显示全部楼层
jason680 发表于 2014-09-10 14:33
回复 78# damcool

maybe it's your issue when you use none-normal number in normal question


Just for pointing out your bug and it does no matter with the number is normal or abnormal. Try others' code, they can work out my sample data just as they should be. So your code has bug.

论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
发表于 2014-09-10 15:45 |显示全部楼层
本帖最后由 jason680 于 2014-09-10 16:05 编辑

回复 83# damcool

OK, please try it for your solution if you just want to get a solution
Note: I didn't have any idea for below abnormal number
and your solution with sort command also had the bug by your define
   
$ cat s
0       10      -       -       -
10000   -       10001   -       1
5.3500000000e+1999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999     -       -       -       0
5.3400000000e+19999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999     -       -       -       0
-       -10000  -       -       -
-       0       -       -       -
-       999     -       10      -
-       -       -       -       -
-       -       100     -       100

$ sort -gr s | awk 'BEGIN{n=1}{if($n=="-"&&$(n+1)!="-")n++;a[n]=a[n]?$0"\n"a[n]:$0}END{for(t=1;t<=n;t++)print a[t]}'
0       10      -       -       -
10000   -       10001   -       1
5.3400000000e+19999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999     -       -       -       0
5.3500000000e+1999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999     -       -       -       0
-       -10000  -       -       -
-       0       -       -       -
-       999     -       10      -
-       -       -       -       -
-       -       100     -       100


论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
发表于 2014-09-10 15:57 |显示全部楼层
本帖最后由 jason680 于 2014-09-10 16:16 编辑

回复 82# blackold

OK, I see.

It isn't big issue for sorting B column when got the same number of A column

1. It's undefined by 楼主 request

2. It can be modified the code easily
   

论坛徽章:
2
白羊座
日期:2013-11-18 19:52:42辰龙
日期:2014-09-07 07:46:06
发表于 2014-09-10 16:38 |显示全部楼层
jason680 发表于 2014-09-10 15:45
回复 83# damcool

OK, please try it for your solution if you just want to get a solution


Congradulations!
You found a bug of sort, you got a chance to report it to the programmer of sort!

论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
发表于 2014-09-10 16:55 |显示全部楼层
回复 86# damcool

nnn, I didn't think it to be a bug ...

It is a number system define issue

sometime you need a car, truck, van, ... depand on your goods

   

论坛徽章:
32
处女座
日期:2013-11-20 23:41:20双子座
日期:2014-06-11 17:20:43戌狗
日期:2014-06-16 11:05:00处女座
日期:2014-07-22 17:30:47狮子座
日期:2014-07-28 15:38:17金牛座
日期:2014-08-05 16:34:01亥猪
日期:2014-08-18 13:34:25白羊座
日期:2014-09-02 15:03:55金牛座
日期:2014-11-10 10:23:58处女座
日期:2014-12-02 09:17:52程序设计版块每日发帖之星
日期:2015-06-16 22:20:002015亚冠之塔什干火车头
日期:2015-06-20 23:28:22
发表于 2014-09-10 18:52 |显示全部楼层
回复 87# jason680

What is the "nnn" mean?  I know "nnd" only.      

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
发表于 2014-09-10 19:16 |显示全部楼层
回复 88# yestreenstars


    Don't mind these things!

论坛徽章:
60
20周年集字徽章-20	
日期:2020-10-28 14:04:3015-16赛季CBA联赛之北京
日期:2016-07-06 15:42:0715-16赛季CBA联赛之同曦
日期:2016-06-12 10:38:0915-16赛季CBA联赛之佛山
日期:2016-05-27 11:54:56黄金圣斗士
日期:2015-12-02 11:44:35白银圣斗士
日期:2015-11-25 14:32:43白银圣斗士
日期:2015-11-23 12:53:352015亚冠之布里斯班狮吼
日期:2015-10-21 16:55:482015亚冠之首尔
日期:2015-09-01 16:46:052015亚冠之德黑兰石油
日期:2015-08-31 11:39:192015亚冠之萨济拖拉机
日期:2015-08-28 21:06:5315-16赛季CBA联赛之广东
日期:2016-07-12 14:58:53
发表于 2014-09-10 19:21 |显示全部楼层
回复 89# blackold


    @yestreenstars 我帮黑哥翻译的: "不要在意这些细节" !
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP