How to make numerical sorting go 1-10, instead of 1, 10, 2, 3, 4, etc.

How to make numerical sorting go 1-10, instead of 1, 10, 2, 3, 4, etc.

emtemt Posts: 46Questions: 10Answers: 0

Hey Allan, is it possible to change the way DT sorts items numerically? For example:

By default, numerical sorting in DT is set like this: 1, 10, 2, 3, 4, 5, 6, 7, 8, 9

My question is, how can I get DT to sort like this: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Sorting shown under Item column

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    You have non-numeric data in the column, which is why DataTables is string sorting the column.

    I think in this case, given the data, the natural sorting plug-in is probably the best solution.

    Allan

This discussion has been closed.