sort id problem
Expected Behavior
for asc 1 2 3 4
for desc 100 99 98 97
Current Behavior
This is my result for asc sort for id
the result should be
10
11
12
and this is my result for desc sort for id
the result should be
92
91
89
code for data mapping
const data = projects.map(p =>[
'${p.id}'
])
code for column ID
const columns = [
{
name: "id",
id: "id",
label: "ID",
options: {
filter: false,
sort:true,}},
| Tech | Version |
|---|---|
| Material-UI | ^3.9.3 |
| MUI-datatables | ^2.0.0 |
| React | ^16.8.6 |
| browser | |
| etc |
I was unable to reproduce this locally on 2.2.0. Can you help me reproduce this by providing your data sets and using it break an existing example from this project? Alternatively, you could open up a codesandbox with a broken example.
actually my data sets is from an api , so i fetch it in the root files and i pass it as a props to my table , and then mapping it to data
this is my codesandbox, hopefully can help you https://codesandbox.io/embed/vigilant-buck-c8g7u?fontsize=14
sorry for my english
Thank you for providing that.
The problem is that you are mapping the id to a string value: ${p.id}, so it is being treated and sorted as such. What you want is to map it as a numerical value: p.id. Then sorting will work as you expect.
Yes, it worked. Thank you for your help.
Can i ask your help again ? this is my issue #636 i want to sort column with array value in it
I responded to the other thread. Did you get what you needed for this issue? Ok if I close it?
Yep you can close it, thank you so much