Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js |
— | — | @@ -212,4 +212,47 @@ |
213 | 213 | } |
214 | 214 | ); |
215 | 215 | |
| 216 | +var ipv4 = [ |
| 217 | + // Some randomly generated fake IPs |
| 218 | + ['45.238.27.109'], |
| 219 | + ['44.172.9.22'], |
| 220 | + ['247.240.82.209'], |
| 221 | + ['204.204.132.158'], |
| 222 | + ['170.38.91.162'], |
| 223 | + ['197.219.164.9'], |
| 224 | + ['45.68.154.72'], |
| 225 | + ['182.195.149.80'] |
| 226 | +]; |
| 227 | +var ipv4Sorted = [ |
| 228 | + // Sort order should go octet by octet |
| 229 | + ['44.172.9.22'], |
| 230 | + ['45.68.154.72'], |
| 231 | + ['45.238.27.109'], |
| 232 | + ['170.38.91.162'], |
| 233 | + ['182.195.149.80'], |
| 234 | + ['197.219.164.9'], |
| 235 | + ['204.204.132.158'], |
| 236 | + ['247.240.82.209'] |
| 237 | +]; |
| 238 | +tableTest( |
| 239 | + 'Bug 17141: IPv4 address sorting', |
| 240 | + ['IP'], |
| 241 | + ipv4, |
| 242 | + ipv4Sorted, |
| 243 | + function( $table ) { |
| 244 | + $table.tablesorter(); |
| 245 | + $table.find('.headerSort:eq(0)').click(); |
| 246 | + } |
| 247 | +); |
| 248 | +tableTest( |
| 249 | + 'Bug 17141: IPv4 address sorting (reverse)', |
| 250 | + ['IP'], |
| 251 | + ipv4, |
| 252 | + reversed(ipv4Sorted), |
| 253 | + function( $table ) { |
| 254 | + $table.tablesorter(); |
| 255 | + $table.find('.headerSort:eq(0)').click().click(); |
| 256 | + } |
| 257 | +); |
| 258 | + |
216 | 259 | })(); |
Index: trunk/phase3/resources/jquery/jquery.tablesorter.js |
— | — | @@ -726,7 +726,9 @@ |
727 | 727 | l = a.length; |
728 | 728 | for ( var i = 0; i < l; i++ ) { |
729 | 729 | var item = a[i]; |
730 | | - if ( item.length == 2 ) { |
| 730 | + if ( item.length == 1 ) { |
| 731 | + r += "00" + item; |
| 732 | + } else if ( item.length == 2 ) { |
731 | 733 | r += "0" + item; |
732 | 734 | } else { |
733 | 735 | r += item; |