Donavan White
Donavan White

Reputation: 1126

Thinking Sphinx sorting integers descending doesn't sort by highest to lowest value

I'm new to using Sphinx and the Thinking Sphinx gem. I have a column that has up to 6 digit integers in it, when I do a sort on that column I'm only getting up to 5 digits by default and when it is ordering them it is doing it by only the first digit so it looks like this

99999
99998
99997
...
89999
...
79999
...
100999 <- Higher 6 digit number showing up here
10999
10998

even though I have numbers higher than 99999 this so it should look like this

100999
100998
100997
...
...
99999
99998

any help is much appreciated

Upvotes: 0

Views: 223

Answers (1)

Anthony Alberto
Anthony Alberto

Reputation: 10395

Make sure that you store integers as integers in your DB.

If it's in a string, no one will complain and everything'll work fine until you want to sort them :)

Upvotes: 1

Related Questions