UNPKG

tablesort

Version:

A sorting component for HTML tables

6 lines 857 B
/*! * tablesort v5.2.1 (2021-10-30) * http://tristen.ca/tablesort/demo/ * Copyright (c) 2021 ; Licensed MIT */ !function(){var a=function(a,b){return a=parseFloat(a),b=parseFloat(b),a=isNaN(a)?0:a,b=isNaN(b)?0:b,a-b},b=function(a){return a.replace(/[^\-?0-9.]/g,"")},c=function(a){a=a.toLowerCase();var b="i"===a[1]?1024:1e3;switch(a[0]){case"k":return Math.pow(b,2);case"m":return Math.pow(b,3);case"g":return Math.pow(b,4);case"t":return Math.pow(b,5);case"p":return Math.pow(b,6);case"e":return Math.pow(b,7);case"z":return Math.pow(b,8);case"y":return Math.pow(b,9);default:return b}},d=function(a){var d=a.match(/^(\d+(\.\d+)?) ?((K|M|G|T|P|E|Z|Y|B$)i?B?)$/i),e=parseFloat(b(d[1])),f=d[3];return e*c(f)};Tablesort.extend("filesize",function(a){return/^\d+(\.\d+)? ?(K|M|G|T|P|E|Z|Y|B$)i?B?$/i.test(a)},function(b,c){return b=d(b),c=d(c),a(c,b)})}();