Skip to content

Conversation

iamdevman
Copy link

Added support for sorting numbers.

@apuchkov
Copy link
Owner

It already supports sorting by numbers. See example here http://apuchkov.com/knockout-orderable/examples/basic.html
Can you tell which specific use case you are trying to solve with this?
Thanks

@apuchkov apuchkov closed this May 19, 2013
@jonathanhallee
Copy link

It does in fact support number sorting, but not in all cases. As i can see, it sorts numbers "alphabetically". Meaning that all numbers starting with 9 will be before numbers starting with 8 etc.... depending on the sort order.

However, this has an issue when it comes to larger numbers such as my case (see image, column is sorted in descending order) :
image

As you can see, the number 973676 should be out in first, before 99344, hence my comment on alphabetical ordering.

@iamdevman
Copy link
Author

And the code I committed will do a sort based on Numerical order, not alphabetical.

@apuchkov
Copy link
Owner

Latest version sorts numbers correctly, see here http://jsfiddle.net/bqJZC/

@jonathanhallee
Copy link

Don't think i was specific enough. Here is my case : http://jsfiddle.net/bqJZC/1/

Anyway, i've added the support for that case in my version of the code. Basically it just tries to parse into integer & adds support for undefined values.

@apuchkov
Copy link
Owner

I see you store numbers as stings in your ViewModel, this is why it works differently. Will review your change and merge them in a bit later.
Thanks

@apuchkov apuchkov reopened this Jun 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants