Sorting incorrectly - possibly due to decimal

Sorting incorrectly - possibly due to decimal

FlyingBurrito4FlyingBurrito4 Posts: 1Questions: 1Answers: 0
edited July 2014 in Free community support

Hi all:

Working on this table here:
http://sidelinescouting.com/nbla/draft/

It is working exactly the way I want it, aside from some inconsistent behavior -- the numbers are sorting correctly in all the columns, except the 6 to the right, where it sorts something like:

  • 1.99
  • 10.11
  • 10.36
  • 10.63
  • 11.25
  • 12.50
  • 19.75
  • 2.00

I understand why it is doing this, but I don't know how to fix it (or why the columns more to the left are sorting fine, despite them also being numbers and decimal based).

I did look into the Sorting Plugins, as well as did many Google searches for the solution, but couldn't find exactly what I was looking for.

Guessing this is a pretty easy fix for some of you, so any help is appreciated!

Answers

  • tangerinetangerine Posts: 3,244Questions: 30Answers: 385

    I believe your problem is that the data in the right-most columns is not consistently numeric; I can't remember what the solution might be, but I know this has cropped up before - try a forum search.

  • allanallan Posts: 57,686Questions: 1Answers: 9,195 Site admin

    Yup - there is non-numeric data in the columns (TBD in this case), so DataTables can't sort it numerically by default since it sees the string.

    You need to create a sorting plug-in which will sort numerically, seeing the TBD string to -Infinity or something like that. Example plug-in sorting function: http://datatables.net/examples/plug-ins/sorting_manual.html .

    Allan

This discussion has been closed.