couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benoit Chesneau <bchesn...@gmail.com>
Subject Re: Hierarchical comments Hacker News style
Date Mon, 21 May 2012 08:00:57 GMT
To answer to the question as I said in a previous mail you can use the
local sequence to order the results:

https://github.com/benoitc/nymphormation/blob/master/nymphormation/views/comments_subtree/map.js#L9

- benoît

On Mon, May 21, 2012 at 9:34 AM, Dave Cottlehuber <dave@muse.net.nz> wrote:
> On 21 May 2012 04:42, Jim Klo <jim.klo@sri.com> wrote:
>
>> 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?
>>
>
> That's a useful tip - thanks Jim!
>
> A+
> Dave

Mime
View raw message