我需要使用unix排序对一些数据进行排序,但我无法确切地说出正确的语法,数据看起来像
3.9.1 Step 10:
3.9.1 Step 20:
3.8.10 Step 20:
3.10.2 Step 10:
3.8.4 Step 90:
3.8.4 Step 100:
3.8.4 Step 10:
Run Code Online (Sandbox Code Playgroud)
我想首先使用主要数字,然后是步骤编号对其进行排序,例如,上面排序的数据看起来像.
3.8.4 Step 10:
3.8.4 Step 90:
3.8.4 Step 100:
3.8.10 Step 20:
3.9.1 Step 10:
3.9.1 Step 20:
3.10.2 Step 10:
Run Code Online (Sandbox Code Playgroud)
我找到了按此网站上的第一个数字排序的方法:
sort -t. -k 1,1n -k 2,2n -k 3,3n
Run Code Online (Sandbox Code Playgroud)
但我现在正在努力排序第3列步骤编号,而不会打扰第一类
假设我有一个char数组,这没关系:
char myChars[100] = "hello";
Run Code Online (Sandbox Code Playgroud)
但如果我有一个
const char* hello="hello";
char myChars[100] = hello;
Run Code Online (Sandbox Code Playgroud)
要么
const char hello[6]="hello";
char myChars[100] = hello;
Run Code Online (Sandbox Code Playgroud)
这不被允许:
error: array must be initialized with a brace-enclosed intializer
Run Code Online (Sandbox Code Playgroud)
在我看来,这些基本上是等价的陈述,为什么会这样呢?