to your HTML Add class="sortable" to any table you'd like to make sortable Click on the headers to sort Thanks to many, many people for contributions and suggestions. Licenced as X11: http://www.kryogenix.org/code/browser/licence.html This basically means: do what you want with it. */ var stIsIE = /*@cc_on!@*/false; sorttable = { init: function() { // quit if this function has already been called if (arguments.callee.done) return; // flag this function so we don't do the same thing twice arguments.callee.done = true; // kill the timer if (_timer) clearInterval(_timer); if (!document.createElement || !document.getElementsByTagName) return; sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; forEach(document.getElementsByTagName('table'), function(table) { if (table.className.search(/\bsortable\b/) != -1) { sorttable.makeSortable(table); } }); }, makeSortable: function(table) { if (table.getElementsByTagName('thead').length == 0) { // table doesn't have a tHead. Since it should have, create one and // put the first table row in it. the = document.createElement('thead'); the.appendChild(table.rows[0]); table.insertBefore(the,table.firstChild); } // Safari doesn't support table.tHead, sigh if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; if (table.tHead.rows.length != 1) return; // can't cope with two header rows // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as // "total" rows, for example). This is B&R, since what you're supposed // to do is put them in a tfoot. So, if there are sortbottom rows, // for backwards compatibility, move them to tfoot (creating it if needed). sortbottomrows = []; for (var i=0; i
As both an analyst and as a coder, I'm always on the lookout for new and interesting applications being put online. On occasion, I come across some really incredible or just plain neat tools that are well worth sharing. Recently, in looking at a comparison of the economic performance of the older countries of the European Union (EU) versus individual states in the United States (US), I came across a neat tool from the U.S. Bureau of Economic Analysis, which allows you to create maps showing how much economic activity is generated in various industries in each state.
The following image, which was generated using the tool with some very minor editing to fit the Political Calculations(TM) site layout, shows the states divided into five groups based upon their 2002 Gross State Product (GSP) - the state equivalent of Gross Domestic Product (GDP):
The application is really neat because you can also produce maps showing the contributions of various industries in the states to their Gross State Product. Want to create a map showing the state-by-state output of the textile industry in the US? Oil and gas extraction? Government spending? Try it out!
The weak point of this tool is that it doesn't necessarily offer the data you want. In this case, I was looking for data related to Gross State Product per Capita for each state. That meant some number crunching using an offline spreadsheet application. So after taking the individual GSP data for each state from the previous application, collecting the estimated state population data from the U.S. Census Bureau, and doing the math (dividing the GSP data by the population for each state), I produced a table that looked something like the table below.
The problem though is that if I wanted to rank the individual states by their raw GSP or their per capita GSP and present it online, I would have to create several different tables, which would make for some serious scrolling for the reader. Unless, of course, I used another cool application that would dynamically do the job of ranking the data from richest to poorest or vice versa. Try it out with the table below - you may rank the data either from least to greatest or greatest to least in the table below by clicking the individual column heads:
2002 U.S. Gross State Product and Population Data |
---|
State | GSP ($USD Millions) | Population | GSP per Capita ($USD) |
---|---|---|---|
Alabama | 125567 | 4486508 | 27988 |
Alaska | 29708 | 643786 | 46146 |
Arizona | 171781 | 5456453 | 31482 |
Arkansas | 71929 | 2710079 | 26541 |
California | 1367785 | 35116033 | 38950 |
Colorado | 179410 | 4506542 | 39811 |
Connecticut | 165744 | 3460503 | 47896 |
Delaware | 47150 | 807385 | 58398 |
District of Columbia | 66440 | 570898 | 116378 |
Florida | 520500 | 16713149 | 31143 |
Georgia | 305829 | 8560310 | 35726 |
Hawaii | 43998 | 1244898 | 35343 |
Idaho | 38558 | 1341131 | 28750 |
Illinois | 486139 | 12600620 | 38580 |
Indiana | 204946 | 6159068 | 33275 |
Iowa | 98232 | 2936760 | 33449 |
Kansas | 89508 | 2715884 | 32957 |
Kentucky | 122282 | 4092891 | 29877 |
Louisiana | 131584 | 4482646 | 29354 |
Maine | 39039 | 1294464 | 30158 |
Massachusetts | 201879 | 5458137 | 36987 |
Maryland | 288088 | 6427801 | 44819 |
Michigan | 351287 | 10050446 | 34952 |
Minnesota | 200061 | 5019720 | 39855 |
Mississippi | 69136 | 2871782 | 24074 |
Missouri | 187543 | 5672579 | 33061 |
Montana | 23773 | 909453 | 26140 |
Nebraska | 60962 | 1729180 | 35255 |
Nevada | 81182 | 2173491 | 37351 |
New Hampshire | 46448 | 1275056 | 36428 |
New Jersey | 380169 | 8590300 | 44256 |
New Mexico | 53515 | 1855059 | 28848 |
New York | 792058 | 19157532 | 41344 |
North Carolina | 300216 | 8320146 | 36083 |
North Dakota | 19780 | 634110 | 31193 |
Ohio | 388224 | 11421267 | 33991 |
Oklahoma | 95126 | 3493714 | 27228 |
Oregon | 115138 | 3521515 | 32696 |
Pennsylvania | 428950 | 12335091 | 34775 |
Rhode Island | 36988 | 1069725 | 34577 |
South Carolina | 122354 | 4107183 | 29790 |
South Dakota | 25003 | 761063 | 32853 |
Tennessee | 190122 | 5797289 | 32795 |
Texas | 773455 | 21779893 | 35512 |
Utah | 72974 | 2316256 | 31505 |
Vermont | 19604 | 616592 | 31794 |
Virginia | 287589 | 7293542 | 39431 |
Washington | 232940 | 6068996 | 38382 |
West Virginia | 45518 | 1801873 | 25261 |
Wisconsin | 190650 | 5441196 | 35038 |
Wyoming | 20285 | 498703 | 40676 |
One item to note - in the table above, I originally used commas to separate the hundreds, thousands, millions, etc. in the format of the numbers presented. The table sorting function had problems with properly sorting the data with the commas in place, as well as any other separator I tried (spaces, periods, etc.), so the numbers are therefore presented without them.
Gross State Product (GSP) Data: U.S. Bureau of Economic Analysis
2002 Population Estimate: U.S. Census Bureau
Table Sorting Function: The Daily Kryogenix
Welcome to the blogosphere's toolchest! Here, unlike other blogs dedicated to analyzing current events, we create easy-to-use, simple tools to do the math related to them so you can get in on the action too! If you would like to learn more about these tools, or if you would like to contribute ideas to develop for this blog, please e-mail us at:
ironman at politicalcalculations
Thanks in advance!
Closing values for previous trading day.
This site is primarily powered by:
The tools on this site are built using JavaScript. If you would like to learn more, one of the best free resources on the web is available at W3Schools.com.