Contents
- Original Table
- Column 1 No Sort
- Column 1 Reverse No Sort
- Column 1 Alphabetical
- Column 1 Reverse Alphabetical
- Column 1 Case-Insensitive
- Column 2 Numerical
- Column 2 Alphabetical
- Column 2 Reverse Numerical
- Column 3 Alphabetical
- Column 3 Numerical
- Column 1 Alphabetical, Column 2 Numerical, Column 3 Alphabetical
- Column 1 Case-Insensitive, Column 2 Numerical, Column 3 Case-Insensitive
- Zero Header Rows, Case-Insensitive Sort on Column 1
- Three Header Rows, Case-Insensitive Sort on Column 1
- Invalid Argument Examples
Original Table
First |
Second |
Third |
A |
2,000,000 |
zebra |
C |
1 |
123 |
b |
2 |
word |
d |
30 |
word |
A |
2 |
Wordy |
B |
4.2 |
23 |
A |
2 |
word |
Column 1 No Sort
<<SortBy(SortByTest, 1, 1, nosort)>>
First |
Second |
Third |
A |
2,000,000 |
zebra |
C |
1 |
123 |
b |
2 |
word |
d |
30 |
word |
A |
2 |
Wordy |
B |
4.2 |
23 |
A |
2 |
word |
This simply includes the first table on the source page at this point in the page containing the macro. Rows are in the same order as the original table.
Column 1 Reverse No Sort
<<SortBy(SortByTest, 1, 1, reversenosort)>>
First |
Second |
Third |
A |
2 |
word |
B |
4.2 |
23 |
A |
2 |
Wordy |
d |
30 |
word |
b |
2 |
word |
C |
1 |
123 |
A |
2,000,000 |
zebra |
Similar to the previous example, but now all rows except the one header row are in reverse order.
Column 1 Alphabetical
<<SortBy(SortByTest, 1, 1, alpha)>>
First |
Second |
Third |
A |
2,000,000 |
zebra |
A |
2 |
Wordy |
A |
2 |
word |
B |
4.2 |
23 |
C |
1 |
123 |
b |
2 |
word |
d |
30 |
word |
In alphabetical order all uppercase letters are sorted before lowercase letters.
Column 1 Reverse Alphabetical
<<SortBy(SortByTest, 1, 1, reversealpha)>>
First |
Second |
Third |
d |
30 |
word |
b |
2 |
word |
C |
1 |
123 |
B |
4.2 |
23 |
A |
2,000,000 |
zebra |
A |
2 |
Wordy |
A |
2 |
word |
Prepending 'reverse' to the sort-type changes the order from ascending to descending.
Column 1 Case-Insensitive
<<SortBy(SortByTest, 1, 1, nocase)>>
First |
Second |
Third |
A |
2,000,000 |
zebra |
A |
2 |
Wordy |
A |
2 |
word |
b |
2 |
word |
B |
4.2 |
23 |
C |
1 |
123 |
d |
30 |
word |
Now 'B' and 'b' are considered equal, and are presented in the order they appear in the original table.
Column 2 Numerical
<<SortBy(SortByTest, 1, 2, number)>>
First |
Second |
Third |
C |
1 |
123 |
b |
2 |
word |
A |
2 |
Wordy |
A |
2 |
word |
B |
4.2 |
23 |
d |
30 |
word |
A |
2,000,000 |
zebra |
As you would expect, 30 comes before 2,000,000. Commas are ignored for sorting. Integers and floating point can both be used, and they sort correctly.
Column 2 Alphabetical
<<SortBy(SortByTest, 1, 2, alpha)>>
First |
Second |
Third |
C |
1 |
123 |
b |
2 |
word |
A |
2 |
Wordy |
A |
2 |
word |
A |
2,000,000 |
zebra |
d |
30 |
word |
B |
4.2 |
23 |
In 'alphabetical' order, 2 comes before 3, so 2,000,000 sorts before 30.
Column 2 Reverse Numerical
<<SortBy(SortByTest, 1, 2, reversenumber)>>
First |
Second |
Third |
A |
2,000,000 |
zebra |
d |
30 |
word |
B |
4.2 |
23 |
b |
2 |
word |
A |
2 |
Wordy |
A |
2 |
word |
C |
1 |
123 |
Again, prepending 'reverse' to the sort-type changes the order from ascending to descending.
Column 3 Alphabetical
<<SortBy(SortByTest, 1, 3, alpha)>>
First |
Second |
Third |
C |
1 |
123 |
B |
4.2 |
23 |
A |
2 |
Wordy |
b |
2 |
word |
d |
30 |
word |
A |
2 |
word |
A |
2,000,000 |
zebra |
Wiki formatting is ignored, and the sort is stable. The variations of 'word' are simply listed in the same order as they appear in the original table.
Column 3 Numerical
<<SortBy(SortByTest, 1, 3, number)>>
First |
Second |
Third |
B |
4.2 |
23 |
C |
1 |
123 |
A |
2 |
Wordy |
b |
2 |
word |
d |
30 |
word |
A |
2 |
word |
A |
2,000,000 |
zebra |
Now 23 comes before 123, and non-numeric values are sorted in alphabetical order as above.
Column 1 Alphabetical, Column 2 Numerical, Column 3 Alphabetical
<<SortBy(SortByTest, 1, 1, alpha, 2, number, 3, alpha)>>
First |
Second |
Third |
A |
2 |
Wordy |
A |
2 |
word |
A |
2,000,000 |
zebra |
B |
4.2 |
23 |
C |
1 |
123 |
b |
2 |
word |
d |
30 |
word |
The main sort is on column 1, but within the duplicate 'A's the 2's and 2,000,000 are sorted, and within the 2's the values in column 3 are in case-sensitive alphabetical order.
Column 1 Case-Insensitive, Column 2 Numerical, Column 3 Case-Insensitive
<<SortBy(SortByTest, 1, 1, nocase, 2, number, 3, nocase)>>
First |
Second |
Third |
A |
2 |
word |
A |
2 |
Wordy |
A |
2,000,000 |
zebra |
b |
2 |
word |
B |
4.2 |
23 |
C |
1 |
123 |
d |
30 |
word |
The main sort is still on column 1, but within the case-insensitive duplicate 'b's the values in column 2 are in numerical order. Also, within the duplicate A-2 rows, column 3 is case-insensitive, so now Wordy follows word.
Zero Header Rows, Case-Insensitive Sort on Column 1
<<SortBy(SortByTest, 0, 1, nocase)>>
A |
2,000,000 |
zebra |
A |
2 |
Wordy |
A |
2 |
word |
b |
2 |
word |
B |
4.2 |
23 |
C |
1 |
123 |
d |
30 |
word |
First |
Second |
Third |
The first row is sorted along with all the other rows.
Three Header Rows, Case-Insensitive Sort on Column 1
<<SortBy(SortByTest, 3, 1, nocase)>>
First |
Second |
Third |
A |
2,000,000 |
zebra |
C |
1 |
123 |
A |
2 |
Wordy |
A |
2 |
word |
b |
2 |
word |
B |
4.2 |
23 |
d |
30 |
word |
The first three rows are not sorted along with all the other rows.
Invalid Argument Examples
[[SortBy(NonExistentPage, 1, 1, nocase)]]
SortBy: Unable to open the table page "NonExistentPage"
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, 1, 1)]]
SortBy: Not enough arguments (3).
At least 4 are required.
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, x, 1, alpha)]]
SortBy: Number of header rows (x)
must be an integer
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, 1, x, alpha)]]
SortBy: Column number (x) must be an integer
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, -1, 1, alpha)]]
SortBy: Number of header rows (-1)
must be a positive integer
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, 10, 1, alpha)]]
SortBy: Number of header rows (10) is more than
the table length (8)
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, 1, 0, alpha)]]
SortBy: Column number (0) must be 1 or higher.
1 = leftmost column
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, 1, 10, alpha)]]
SortBy: Column number (10) is higher than
the length of one or more rows
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, 1, 1, x)]]
SortBy: Invalid sort type "x"
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber
[[SortBy(SortByTest, 1, 1, alpha, 1)]]
SortBy: Odd number of arguments (5)
Usage: SortBy(TablePage, <number of header rows>,
<primary sort column number>, <sort type>
[, <secondary sort column>, <sort type>] ... )
Valid sort types are: alpha nocase nosort number reversealpha reversenocase reversenosort reversenumber