Reputation: 61
So I have a table that have alpha-numeric values for example:
8980
1100
A1100
BA200
I want it to sort it in a numeric order fashion first and then in alpha-numeric fashion e.g.
1000
8980
A1100
BA200
Found some help here but not exactly the thing I am looking for: http://datatables.net/forums/discussion/367/bug-sort-number-column-and-stype
Is there a way to achieve this using any API?
Upvotes: 3
Views: 8441
Reputation: 58900
SOLUTION
Use Natural sorting plug-in to sort data with a mix of numbers and letters naturally.
For example, use the code below to sort first column (targets: 0
) using natural sorting plug-in.
var table = $('#example').DataTable({
columnDefs: [ { targets: 0, type: 'natural' } ]
});
Don't forget to include plug-in JavaScript file.
DEMO
See this jsFiddle for code and demonstration.
Upvotes: 7