-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table sorting by text length or alphabetically? #1792
Comments
You can specify your own sort algorithm. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort |
for sort by alpgavite: |
It would be better to use JavaScript String#localeCompare function: sorter: (a, b) => { return a.title.localeCompare(b.title)}, |
thx @Leong21 for this clever solution |
I'm still unable to figure out how can we sort columns using Dates. I'm doing something like:
But this isn't working. |
@ghoshnirmalya try using moment.js if possible. sorter: (a, b) => { return moment(a.publishedAt).unix() - moment(b.publishedAt).unix()} in order to handle the situation where publishedAt == "" try: |
@Leong21 Thank you! That works as expected. |
Good work @ leong21 |
@Leong21 Thank you! This should be explained or mentioned here:https://vue.ant.design/components/table/ |
There is also a solution like this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/Collator |
The table sorter is sorting text strings by length not alphabetically. I do not know how is this in Chinese language but in euro american countries sorting of text is done alphabetically.
The text was updated successfully, but these errors were encountered: