Hi,
thanks for your post, and sorry for the trouble.
The problem with that format likely is that there’s no number in the “Free” value. The sorting algorithm however would require that (as it strips all characters).
An alternative approach for such custom search terms is https://wordpress.org/support/topic/date-order-6/ which deals with a very similar scenario.
Regards,
Tobias
Thread Starter
Pluh
(@pluh)
Would adding a number in a div tag and hiding it via CSS help? Basically the sorting plugin will have a number to work with.
Hi,
that might actually work, yes.
Regards,
Tobias
Thread Starter
Pluh
(@pluh)
That doesn’t seem to help either. Should I add any custom sorting through the sorting plugin?
I also have a file size column and use only numbers like 5GB, 10GB… I tried sorting them by file-size but they still won’t sort properly. I tried adding a space like 5 GB, 10 GB…but it still doesn’t work.
Hi,
Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!
Regards,
Tobias
Thread Starter
Pluh
(@pluh)
Actually I just found out what’s causing the issue. It actually sorts them based on the first digit of the actual number. So they are sorted like this:
10000
20
312412
5
Instead of the actual full number. What should I do in such cases?
columnDefs: [{ “type”: “natural”, “targets”: 2 }] doesn’t work.
I haven’t published my post yet so I cannot send you a link, sorry.
Adding a hidden (via CSS) number does work, but I’d rather find a better solution. I avoid hiding elements via CSS since google and other crawlers will crawl it anyway.
-
This reply was modified 8 years, 2 months ago by
Pluh.
-
This reply was modified 8 years, 2 months ago by
Pluh.
Hi,
it’s sorting after the first digit only because it’s sorting this columns as text/strings, and not as numbers. This happens because there is also text/characters in that column.
Instead of using “natural”, please also try “num-fmt”. And keep in mind that the 2 in your “targets” means third column, just in case.
Regards,
Tobias
Thread Starter
Pluh
(@pluh)
Actually after trying columnDefs: [{ “type”: “num-fmt”, “targets”: 2 }], the whole sorting function seems to disappear from the whole table. So I can’t even sort them in any way after using that (the arrows are missing)
Hi,
I think it would really be the best if I could take a direct look at this. Can you maybe publish this as a test page somehow?
Regards,
Tobias
Thread Starter
Pluh
(@pluh)
Hi,
thanks for the link! The problem here is that you are not using the proper quotation marks " (from typing via keyboard), but typographically nicer ones “ (which you get from copy/pasting the code from somewhere).
Note the difference between (the wrong)
columnDefs: [{ “type”: “num-fmt”, “targets”: 2 }]
and (the correct)
columnDefs: [{ "type": "num-fmt", "targets": 2 }]
Now, in your case, you will probably also run into problems because of the toolips that you are showing (with the little “i” icon). For this column, the best approach should really be what I mentioned in my first reply.
Regards,
Tobias
Thread Starter
Pluh
(@pluh)
Oh man I didn’t even notice those.
Thank you for your help!
Not sure if you can, but please remove the link I posted earlier. I can’t edit my post anymore
-
This reply was modified 8 years, 2 months ago by
Pluh.
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
No, sorry, I can’t remove the URL, as I’m not a moderator here.
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!