diff --git a/sorting/numeric-comma.js b/sorting/numeric-comma.js index 89264a9..5e5cb27 100644 --- a/sorting/numeric-comma.js +++ b/sorting/numeric-comma.js @@ -3,6 +3,10 @@ * decimal place. This sorting plug-in shows how that can be taken account of in * sorting by adding the type 'numeric-comma' to DataTables. A type detection * plug-in for this sorting method is provided below. + * + * Please note that the 'Formatted numbers' type detection and sorting plug-ins + * offer greater flexibility that this plug-in and should be used in preference + * to this method. * @name Commas for decimal place * @anchor numeric_comma * @author Allan Jardine diff --git a/type-detection/numeric-comma.js b/type-detection/numeric-comma.js index f971a48..0bfdcca 100644 --- a/type-detection/numeric-comma.js +++ b/type-detection/numeric-comma.js @@ -1,6 +1,10 @@ /** * Automatically detect numbers which use a comma in the place of a decimal * point to allow them to be sorted numerically. + * + * Please note that the 'Formatted numbers' type detection and sorting plug-ins + * offer greater flexibility that this plug-in and should be used in preference + * to this method. * @name Commas for decimal place * @anchor numeric_comma * @author Allan Jardine @@ -9,28 +13,24 @@ jQuery.fn.dataTableExt.aTypes.unshift( function ( sData ) { - var sValidChars = "0123456789-,"; + var sValidChars = "0123456789,."; var Char; var bDecimal = false; + var iStart=0; + + /* Negative sign is valid - shift the number check start point */ + if ( sData.charAt(0) === '-' ) { + iStart = 1; + } /* Check the numeric part */ - for ( i=0 ; i