sort string that has number with -

sort string that has number with -

itsmeseema00itsmeseema00 Posts: 4Questions: 2Answers: 0

Hi I am new to datatable and I want to sort a column which has type as String that has number on it. Its sorting as String.

$(document).ready(function() {
$('#dashboard').DataTable({
"order": [[ 0, "desc" ]],
"lengthMenu" : [ [ 25, 50, 75, -1 ], [ 25, 50, 75, "All" ] ],
"pageLength" : 200,
"aoColumns": [ //When i changed the column type to num it sorts in beginning and after that-
{ "sType": "num" }, // -it does not sort.
null,
null,
null,
null,
null,
null,
null
]
});
});

Sample for my sorted column
AR-99
AR-983
AR-982
AR-981
AR-980
AR-98
AR-979
AR-978
AR-977
AR-976
AR-975
IR-99
IR-983
IR-982
IR-981
IR-980
IR-98
IR-979
IR-978
IR-977
IR-976
IR-975
....
....

I want the result as:
AR-983
AR-982
AR-981
AR-980
AR-979
AR-978
AR-977
AR-976
AR-975
...
...
IR-983
IR-982
IR-981
IR-980
IR-979
IR-978
IR-977
IR-976
IR-975
IR-974

Can any one help me with this please?

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.