couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luis Gomez <lgo...@gmail.com>
Subject Re: Sorting padded numbers?
Date Wed, 17 Mar 2010 11:28:21 GMT
Ah... awesome. Simpler than I thought.

ParseInt did the trick but I will store these as numbers instead. That's the
right thing to do in this case.

Thanks!

Luis


On Wed, Mar 17, 2010 at 4:26 AM, Jon Gretar Borgthorsson <
jon.borgthorsson@gmail.com> wrote:

> If you get sorting like that it means that you have strings but not
> numbers.
> Either start using numbers for the values or if that is not possible
> convert
> the string to an integer in the emit function.
>
>   emit(parseInt(doc.my_number), doc);
>
> -- Jón Grétar Borgþórsson
>
>
> On Wed, Mar 17, 2010 at 11:05 AM, Luis Gomez <lgomez@gmail.com> wrote:
>
> > Hi, quick one this time...
> >
> > How can I make a map function sort these keys numerically? Is there an
> > easy/conventional way or do I need to pad the numbers?
> >
> >
> > Thanks,
> >
> > Luis
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message