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
$(function() {
$("table").tablesorter({
theme : 'blue',
widgets : ["zebra"]
});
});
HTML
<table class="tablesorter">
<thead>
<tr><th class="sorter-metric" data-metric-name="b|byte">Metric (binary) Size</th>
<th class="sorter-metric" data-metric-name="m|meter">Metric Length</th>
</tr>
</thead>
<tbody>
<tr><td>1 byte</td><td>1 nm</td></tr>
<tr><td>1 kb</td><td>1 kilometer</td></tr>
<tr><td>1 Gigabyte</td><td>1 Gm</td></tr>
<tr><td>10 Mb</td><td>1 Tm</td></tr>
<tr><td>1 Mb</td><td>1,000 mm</td></tr>
<tr><td>1 Tb</td><td>1 meter</td></tr>
<tr><td>1 Petabyte</td><td>1 hm</td></tr>
<tr><td>1 Zb</td><td>1 dam</td></tr>
<tr><td>1,025 Mb</td><td>1 Mm</td></tr>
<tr><td>1,000 kilobytes</td><td>1 dm</td></tr>
<tr><td>1 Eb</td><td>1 µm</td></tr>
<tr><td>1023 Mb</td><td>1 pm</td></tr>
</tbody>
</table>