On 1/22/07, Yonik Seeley <[EMAIL PROTECTED]> wrote:
An efficient representation using arrays would be two separate arrays:
one for terms, one for counts.
terms=["foo","bar","baz"]
counts=[30,20,10]

But you loose easy random access lookup, and for a sufficiently large
list, you loose the ability of a human to look at the raw response and
correlate a count with the term.

Or if you want to retain the human readability, a single array:
["foo",30,"bar",20,"baz",10]

We could introduce some new types to tell the output handlers just how
important it is to maintain order, so all named lists don't get
treated the same.

Example:
class OrderedNamedList extends NamedList {...}

Using OrderedNamedList, means that it's really important that order be
maintained, and we could a different strategy such as interleaving
keys and values in a single array (or another strategy set by
json.orderednl?)

Thoughts?

-Yonik

So what about something that could output something like
omap("term1",100,"term2", 45)

The other alternative (besides changing *every* named list), is to
have a facet.format and override the default structure.

-Yonik

> > If that's your *only* sorting problem, find a ruby implementation of a
> > hash or a map that preserves order, then re-sort the hash, and replace
> > it with the order-preserving map, and then worry about a more general
> > solution later?
>
> Maybe what we need is a YAML response writer, and used an ordered
> map: http://yaml.org/type/omap.html
>
>         Erik

Reply via email to