Webdoc example of natural sort

This commit is contained in:
John Kerl 2022-02-08 23:53:03 -05:00
parent 98d0a4398a
commit de9e17f73b
3 changed files with 108 additions and 0 deletions

28
docs/src/data/natsort.csv Normal file
View file

@ -0,0 +1,28 @@
n,name
1,Allegia 51 Clasteron
2,Callisto Morphamax 6000 SE
3,Xiph Xlater 58
4,1000X Radonius Maximus
5,20X Radonius Prime
6,30X Radonius
7,Alpha 2
8,Allegia 50 Clasteron
9,Alpha 2A-8000
10,200X Radonius
11,Allegia 50B Clasteron
12,Xiph Xlater 5
13,Callisto Morphamax 700
14,Xiph Xlater 500
15,Alpha 2A-900
16,20X Radonius
17,Callisto Morphamax 6000 SE2
18,Allegia 500 Clasteron
19,Alpha 100
20,Alpha 2A
21,Xiph Xlater 300
22,Callisto Morphamax
23,Callisto Morphamax 7000
24,10X Radonius
25,Xiph Xlater 40
26,Allegia 6R Clasteron
27,Callisto Morphamax 5000
1 n name
2 1 Allegia 51 Clasteron
3 2 Callisto Morphamax 6000 SE
4 3 Xiph Xlater 58
5 4 1000X Radonius Maximus
6 5 20X Radonius Prime
7 6 30X Radonius
8 7 Alpha 2
9 8 Allegia 50 Clasteron
10 9 Alpha 2A-8000
11 10 200X Radonius
12 11 Allegia 50B Clasteron
13 12 Xiph Xlater 5
14 13 Callisto Morphamax 700
15 14 Xiph Xlater 500
16 15 Alpha 2A-900
17 16 20X Radonius
18 17 Callisto Morphamax 6000 SE2
19 18 Allegia 500 Clasteron
20 19 Alpha 100
21 20 Alpha 2A
22 21 Xiph Xlater 300
23 22 Callisto Morphamax
24 23 Callisto Morphamax 7000
25 24 10X Radonius
26 25 Xiph Xlater 40
27 26 Allegia 6R Clasteron
28 27 Callisto Morphamax 5000

View file

@ -89,6 +89,76 @@ yellow circle true 9 87 63.5058 8.3350
yellow triangle true 1 11 43.6498 9.8870
</pre>
Example of natural sort, adapted from [https://github.com/facette/natsort](https://github.com/facette/natsort):
<pre class="pre-highlight-in-pair">
<b>mlr --c2p cat data/natsort.csv</b>
</pre>
<pre class="pre-non-highlight-in-pair">
n name
1 Allegia 51 Clasteron
2 Callisto Morphamax 6000 SE
3 Xiph Xlater 58
4 1000X Radonius Maximus
5 20X Radonius Prime
6 30X Radonius
7 Alpha 2
8 Allegia 50 Clasteron
9 Alpha 2A-8000
10 200X Radonius
11 Allegia 50B Clasteron
12 Xiph Xlater 5
13 Callisto Morphamax 700
14 Xiph Xlater 500
15 Alpha 2A-900
16 20X Radonius
17 Callisto Morphamax 6000 SE2
18 Allegia 500 Clasteron
19 Alpha 100
20 Alpha 2A
21 Xiph Xlater 300
22 Callisto Morphamax
23 Callisto Morphamax 7000
24 10X Radonius
25 Xiph Xlater 40
26 Allegia 6R Clasteron
27 Callisto Morphamax 5000
</pre>
<pre class="pre-highlight-in-pair">
<b>mlr --c2p sort -t name data/natsort.csv</b>
</pre>
<pre class="pre-non-highlight-in-pair">
n name
24 10X Radonius
16 20X Radonius
5 20X Radonius Prime
6 30X Radonius
10 200X Radonius
4 1000X Radonius Maximus
26 Allegia 6R Clasteron
8 Allegia 50 Clasteron
11 Allegia 50B Clasteron
1 Allegia 51 Clasteron
18 Allegia 500 Clasteron
7 Alpha 2
20 Alpha 2A
15 Alpha 2A-900
9 Alpha 2A-8000
19 Alpha 100
22 Callisto Morphamax
13 Callisto Morphamax 700
27 Callisto Morphamax 5000
2 Callisto Morphamax 6000 SE
17 Callisto Morphamax 6000 SE2
23 Callisto Morphamax 7000
12 Xiph Xlater 5
25 Xiph Xlater 40
3 Xiph Xlater 58
21 Xiph Xlater 300
14 Xiph Xlater 500
</pre>
## Sorting fields within records: the sort-within-records verb
The `sort-within-records` verb (see [its

View file

@ -34,6 +34,16 @@ GENMD-RUN-COMMAND
mlr --c2p sort -f color -nr quantity example.csv
GENMD-EOF
Example of natural sort, adapted from [https://github.com/facette/natsort](https://github.com/facette/natsort):
GENMD-RUN-COMMAND
mlr --c2p cat data/natsort.csv
GENMD-EOF
GENMD-RUN-COMMAND
mlr --c2p sort -t name data/natsort.csv
GENMD-EOF
## Sorting fields within records: the sort-within-records verb
The `sort-within-records` verb (see [its