Sorting Tables

By default, table rows are not sorted.

However, if a table contains sorting hints, then psv will automatically sort the rows in the table.

| Animal | type | Color | Avg. Weight | | | --------: | --------^ | ---------- | ---------.v | ------ | | elephant | herbivore | grey | 5_000 kg | skin | | giraffe | herbivore | patchy | 1_000 kg | skin | | crocodile | carnivore | grey | | scales | | lion | carnivore | | 100 kg | fur | | leopard | carnivore | camouflage | 50 kg | fur | | antelope | herbivore | two-tone | 50 kg | fur |

The table above will be sorted by type and then by weight, in descending order.

Sorting Hints

The addition of a ^ or v character to a column's ruler will cause that column to be included when sorting the table.

Pattern Description
^ sort in ascending order (smallest values first)
v sort in descending order (largest values first)
0 .. 7 specify which columns should be compared first

Multiple columns may be marked for sorting.

If the columns should not be compared from left-to-right, an additional priority may be added to the ^ or v character.

Valid priorities are limited to the numbers 0 .. 7, where the columns with priority 1 will be compared first, followed by priority 2, etc., and finally columns with priority 0 (default) .

Note that priority 0 is automatically implied and will not be included in generated tables.

Columns with numerical (. alignment hint) or version (.. alignment hint) alignment will also be sorted according to their numerical values.

Supported Numerical Formats (introductory overview)

Example Description
1234 decimal integers
-1234 signed numbers
12.34 decimal floating point numbers
12.34e2 decimal exponentiation
+12.34e-2 signed exponents
0x0a10 hexadecimal integers
v1.2.3 semver version numbers
Physical Constants: | Symbol | Description | Value | | --:--- | --------------------------------- | -------------------- | | G | Newtonian constant of gravitation | 6.67430e−11 m³/kg/s² | | N(A) | Avogadro constant | 6.02214076e+23 mol⁻¹ | | c | speed of light in a vacuum | 299792458 m/s | | e | elementary charge | 1.602176634e−19 C | | h | Planck constant | 6.62607015e−34 J/Hz | | m(e) | electron mass | 9.1093837139e−31 kg |
  • sort the table of phyical constants by their value

semver versions can also be sorted:

Debian Releases: | name | kernel | release | | -------- | -----..----- | --..--^ | | - | — | 1.0 | | - | 0.99.14t | 0.90 | | - | 0.99.14w | 0.91 | | Bo | 2.0.33 | v1.3 | | Bookworm | 12.10 | 12 | | Bullseye | 11.11 | 11 | | Buster | 10.13 | 10 | | Buzz | 2.0 | 1.1 | | Etch | 4.0r9 | v4.0 | | Hamm | 2.0.34 | v2.0 | | Jessie | 8.11 | 8 | | Lenny | 5.0.10 | 5.0 | | Potato | 2.0.38 | v2.2 | | Rex | 2.0.27 | v1.2 | | Sarge | 2.4.27 | v3.1 | | Slink | 2.0.34 | v2.1 | | Squeeze | 6.0.10 | 6.0 | | Stretch | 9.13 | 9 | | Wheezy | 7.11 | 7 | | Woody | 2.2.20 | v3.0 |