mariuszfoltak/angular2-datatable

Sorting not working as expected when numeric, alphabet and alphanumeric values exists

Opened this issue · 3 comments

Sorting not working as expected when numeric, alphabet and alphanumeric values exists
Here is the example
values: 1, 8, test, 1test, 2test, 22, 3, hello, test22

Expected Ascending order
1, 3, 8, 22, 1test, 2test, hello, test, test22

Do we have any option to extend the existing sorting method or is there any way to call custom sort method

Thanks

Tried with below code.. no luck

name= (name: any) => {
return (!Number.isNaN(Number(name))) ? Number(name) : String(name).toLowerCase();
}

#47

I was looking for the same thing and found this, which then pointed to an example that helped me.

@syeddk did you find a good solution for your sorting problem?
edit:
I am currently using this solution to correctly sortByNumber:
https://gist.github.com/Swamp3/ea660e485e5d18fe844cb1c31047781a