mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

sort id problem

Open mhmmdakbr opened this issue 7 years ago • 7 comments

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 prob3 the result should be 10 11 12

and this is my result for desc sort for id prob4 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

mhmmdakbr avatar May 23 '19 02:05 mhmmdakbr

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.

gabrielliwerant avatar May 23 '19 04:05 gabrielliwerant

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

mhmmdakbr avatar May 23 '19 11:05 mhmmdakbr

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.

gabrielliwerant avatar May 23 '19 18:05 gabrielliwerant

Yes, it worked. Thank you for your help.

mhmmdakbr avatar May 24 '19 06:05 mhmmdakbr

Can i ask your help again ? this is my issue #636 i want to sort column with array value in it

mhmmdakbr avatar May 24 '19 06:05 mhmmdakbr

I responded to the other thread. Did you get what you needed for this issue? Ok if I close it?

gabrielliwerant avatar May 24 '19 07:05 gabrielliwerant

Yep you can close it, thank you so much

mhmmdakbr avatar May 24 '19 07:05 mhmmdakbr