Datatables sorting specific code

Datatables sorting specific code

unbringerunbringer Posts: 2Questions: 1Answers: 0

Hello,
I have problem with sorting of code, which is in link below (for example 10a, 10b, .., 10f, 10g, .., 10z).
https://jsfiddle.net/g0puws36/

I tried use natural sorting plugin, but still not working correctly. Did anyone solving anything similar and can give me advice about it?

Thanks.

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @unbringer ,

    I think you'll have to write a custom ordering plugin for that. The chapter number one could be a good starting point, as it also has multiple components which it breaks apart and multiplies together to get a new comparable number.

    If you have no joy with that, let us know, and we'll see what we can do.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    I was surprised that the natural.js doesn't work. I have data similar to that and it works great. Although my data is in the format of word10a, word10b, etc. I added a column to your test case and added the letter a to the front of each value in the first column. It sorts correctly.

    Maybe there is a simple fix in natural.js. I haven't looked. An alternative would be to use columns.render and prefix a letter or word to the value for the sort type. Refer to this doc if needed:
    https://datatables.net/manual/data/orthogonal-data

    Kevin

  • unbringerunbringer Posts: 2Questions: 1Answers: 0

    Thanks for response!
    I was afraid, that I will need to make own ordering plugin. I will try then, more fun at nights, chapter number one looks very helpful for start.

This discussion has been closed.