Sorting select filter numbers as numbers not strings
Sorting select filter numbers as numbers not strings
![silkspin](https://secure.gravatar.com/avatar/3812353d2f8c471dc900ba2751f8e881/?default=https%3A%2F%2Fvanillicon.com%2F3812353d2f8c471dc900ba2751f8e881_200.png&rating=g&size=120)
I'm guessing there must be an example of this somewhere but I can't find one. I want to sort numbers in a select input filter by either ascending or descending. In this example the salary sorts as a string and not numerically by value.
https://datatables.net/examples/api/multi_filter_select.html
Is this possible?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can perform your own custom sorting. You can use a function with the
sort()
API to customize the sort. Here is an example:http://live.datatables.net/fapavaho/1/edit
It calls the custom function if processing the Salary column.
Kevin
Thanks very much @kthorngren, that is fantastic! It was a bit more complicated than I had expected. I thought something might've already been built in to handle it, but your test works great.