jQuery plugin: Tablesorter - Metric Parser

# tablesorter

## Metric parser

### Flexible client-side table sorting

Back to documentation

NOTE!

- This parser will convert numbers with metric prefixes ("Mega", "Giga", etc) into appropriate values so they are sorted correctly.
- The base name must be included in the header:
  - The base is the unit of measure, such as "byte", "meter", "liter", etc.
  - When saving the base, include both the abbreviation and full name of the base separated by a vertical bar (shift-\) `b|byte`.
  - Store this information within the header's data-attribute (`data-metric-name="b|byte"`).
  - If no base information is found, it will default to `m|meter`.
- Because metric prefixes can be applied to binary values, the parser will calculate the cached value based on the binary multiple, i.e. `"1 kb"` is actually `"1024 bytes"`. See this article for more details.
- This parser does not (yet) support the IEC recommendations for binary prefixes (i.e. "kibibyte (Kib)", "mebibyte (MiB)", etc).
- Supported prefixes include: Yotta (1024), Zetta (1021), Exa (1018), Peta (1015), Tera (1012), Giga (109), Mega (106), kilo (103), hecto (102), deka (101), deci (10-1), centi (10-2), milli (10-3), micro (10-6), nano (10-9), pico (10-12), femto (10-15), atto (10-18), zepto (10-21) and yocto (10-24).
- This demo includes the stored metric values within the table cells, toggle the view using the button below.

# Demo

Metric (binary) Size | Metric Length
--- | ---
1 byte | 1 nm
1 kb | 1 kilometer
1 Gigabyte | 1 Gm
10 Mb | 1 Tm
1 Mb | 1,000 mm
1 Tb | 1 meter
1 Petabyte | 1 hm
1 Zb | 1 dam
1,025 Mb | 1 Mm
1,000 kilobytes | 1 dm
1 Eb | 1 µm
1023 Mb | 1 pm

# Page Header

    <!-- blue theme stylesheet with additional css styles added in v2.0.17 -->
    <link rel="stylesheet" href="../css/theme.blue.css">
    <!-- tablesorter plugin -->
    <script src="../js/jquery.tablesorter.js"></script>

    <!-- load metric parser -->
    <script src="../js/parsers/parser-metric.js"></script>

# Javascript

# HTML

Next up: Applying the filter widget ››