When the data containing character strings and numbers are sorted by using N operation, the following notes are necessary.
Example of specification of key field 1
When the data containing character strings and numbers are sorted by using N operation, the number field is compared only by the value of numbers. Therefore, the output order of the data as the following cannot be expected.
0.9ascaN
Input data | Output result case 1 | Output result case 2 |
---|---|---|
data001 | data001 | data00001 |
data2 | data00001 | data1 |
data1 | data1 | data001 |
data00001 | data2 | data2 |
Point
Considering the number field of 1, 001 and 00001, the value is 1 in all data, data1, data001 and data00001 are judged to have the same key value. If the FIFO (First-in First-out) option is specified, the data is output in the same order as the input order. However, if the FIFO option is not specified, the output order becomes irregular.
Example of specification of key field 2
If the digit numbers are to be considered to sort the data, specify as follows.
0.9ascaN,0.9ascr
Input data | Output result |
---|---|
data001 | data1 |
data2 | data001 |
data1 | data00001 |
data00001 | data2 |
Point
The order of the output is decided as follows.
The order between data001/data1/data00001 and data2 is decided by comparing the first key (0.9ascaN). Since the order becomes definite by the first key comparison, data2 comparison using the second key will no longer be executed.
Then, as the values of the data001/data1/data00001 key are the same, they are compared by the second key (0.9ascr).
The second key is sorted from the biggest to the smallest by comparing the character string. In this example, the character next to the data is used to decide the order. Therefore, data1 is judged as bigger than data001/data00001 and is output first. In the same way, when comparing data001 and data00001, the third figure of data001 stands at 1 while the corresponding figure of data00001 stands at 0. So, data001 is judged as bigger than data00001 and is output secondly. The remaining data, data00001, and data2 which order has already been decided, are output in order, resulting in the above output result.