almende / chap-links-library

a web based visualization library for displaying graphs, networks, and timelines
http://almende.github.com/chap-links-library
Apache License 2.0
599 stars 167 forks source link

Sorting new feature #356

Open ekarudianto opened 8 years ago

ekarudianto commented 8 years ago

I found a bug when I do a sorting based on date, it doesn't sorted out right because it's sorted based on string.. I manage to made a workaround by adding new option which is

sortableType

the default value would be "string" but it could be a date as well.. and also I remove the sorting case sensitive by converting all the strings into lower case

I reallly hope this helps you Jos ! and please review my code if you have time and see if I missed something :)

josdejong commented 8 years ago

Good point, thanks. The sorting now always orders by string value. I think your solution is nice but we can implement a more generic solution by allowing people to provide their own comparator. This allows you to create a custom compare function for every sort of data, not just number, string, and Date. It should be possible to configure a comparator for each individual column.

As for your specific use case: it may be better to provide the date dateEnter as a timestamp or ISOString, and use a format function to display it in a form like "30 Nov, 2015".