incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Klo <jim....@sri.com>
Subject Re: Hierarchical comments Hacker News style
Date Mon, 21 May 2012 02:42:57 GMT
If you're trying to sort hierarchically using integers as id's, assuming the id's grow incrementally
with time (say you were using local_seq), the arrays will naturally sort numerically, whereas
strings are going to sort alphanumerically,  meaning 2, 3, 22, 33 vs "2", "22", "3","33".

Hence,

[ 1, 2 ]
[ 1, 3 ]
[ 1, 3, 10 ]
[ 1, 22 ]
[ 1, 22, 4 ]
[ 1, 22, 5 ]

Which is what I think your intended sort order?



Sent from my iPad

On May 20, 2012, at 5:15 PM, "Keith Gable" <ziggy@ignition-project.com> wrote:

>>> I'm not sure I'm following the whole thread, but why are you storing integers
as strings?
>>> 
>>> If you store them as numbers, they would collate right I think.
>> 
>> Hi Jim,
>> 
>> Can you provide an example?
> 
> I merely provided an example of using integers as integers.
> 
> ---
> Keith Gable
> A+ Certified Professional
> Network+ Certified Professional
> Storage+ Certified Professional
> Mobile Application Developer / Web Developer
> 
> 
> On Sun, May 20, 2012 at 11:25 AM, Luca Matteis <lmatteis@gmail.com> wrote:
>> On Sun, May 20, 2012 at 4:10 PM, Keith Gable <ziggy@ignition-project.com> wrote:
>>> Integers as strings:
>>> 
>>> ["1", "2", "3"]
>>> 
>>> Integers as integers:
>>> 
>>> [1, 2, 3]
>> 
>> Okay, but how does that help with the question at hand?

Mime
View raw message