How can I sort words in a particular order?
How can I sort words in a particular order?
rotaercz
Posts: 31Questions: 7Answers: 0
Say I have a column that will be populated with the following words:
Legendary, Rare, Uncommon, Common
I can't sort this alphabetically because the sorting would be wrong. How can I sort this in the above respective order?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Probably what I would do is use Orthogonal Data and assign a numeric value to each word for the sort operation.
Kevin
Yep, as Kevin, said that's the way to go - see here.
C
Thank you!
This was working well but after I made it a button it sorts alphabetically again. Is there a way to ignore the <a></a> html?
You can just fiddle with that string within the render function in the same way, it will just need to look inside the element
The data variable is empty when I create the rows with <a></a> html but when I create the rows without the extra html I can see the string.
How are you creating the rows?
Maybe you can provide a test case so we can help.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Oh never mind! Actually, the problem was because when initializing I had a 'columns' and a 'columnDefs' after it. I removed the columnDef and just added the render code you provided to columns and I'm getting the string! Thanks for helping me. I appreciate it.