Displaying items from a dictionary collection in a given order?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Displaying items from a dictionary collection in a given order?

Gilles Schtickzelle
Hello,

I have a seaside component that I use to display a list of items pulled from a dictionary.
They appear to be in random order and I'd like to have them displayed in alphabetical or reverse alphabetical order.
I don't really want to have an intermediary orderedCollection that I would display instead, as I would like to add to and delete items from the dictionary directly and see the changes in the component without having to repopulate the intermediary collection.

Is that any way to do that?

Thanks,
Gilles

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Displaying items from a dictionary collection in a given order?

SeanTAllen
No.

A Dictionary is by definition unordered. If you want to order the keys, you have to get them and order them based on your rules.

On Sat, Oct 23, 2010 at 2:12 PM, Gilles Schtickzelle <[hidden email]> wrote:
Hello,

I have a seaside component that I use to display a list of items pulled from a dictionary.
They appear to be in random order and I'd like to have them displayed in alphabetical or reverse alphabetical order.
I don't really want to have an intermediary orderedCollection that I would display instead, as I would like to add to and delete items from the dictionary directly and see the changes in the component without having to repopulate the intermediary collection.

Is that any way to do that?

Thanks,
Gilles

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Displaying items from a dictionary collection in a given order?

sebastianconcept@gmail.co
In reply to this post by Gilles Schtickzelle
I'd take a look at the XMLOrderPreservingDictionary from XML-Parser




On Oct 23, 2010, at 4:12 PM, Gilles Schtickzelle wrote:

Hello,

I have a seaside component that I use to display a list of items pulled from a dictionary.
They appear to be in random order and I'd like to have them displayed in alphabetical or reverse alphabetical order.
I don't really want to have an intermediary orderedCollection that I would display instead, as I would like to add to and delete items from the dictionary directly and see the changes in the component without having to repopulate the intermediary collection.

Is that any way to do that?

Thanks,
Gilles
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Displaying items from a dictionary collection in a given order?

Levente Uzonyi-2
In reply to this post by Gilles Schtickzelle
On Sat, 23 Oct 2010, Gilles Schtickzelle wrote:

> Hello,
>
> I have a seaside component that I use to display a list of items pulled from
> a dictionary.
> They appear to be in random order and I'd like to have them displayed in
> alphabetical or reverse alphabetical order.
> I don't really want to have an intermediary orderedCollection that I would
> display instead, as I would like to add to and delete items from the
> dictionary directly and see the changes in the component without having to
> repopulate the intermediary collection.
>
> Is that any way to do that?

If you have enough the time to render the full contents of the dictionary,
then you probably have the time to create a sorted copy of the dictionary
and render that. Your component will have to apply the updates to the
dictionary.

If you render the full contents only once and update the list via ajax or
websockets then do the sorting/inserting/removing in the browser and only
the updates on the server side.

If you don't render the full contents, then:
- if updates are infrequent, then you can cache the sorted values and use
that for rendering
- if the updates are frequent, then you better use a tree based dictionary
implementation. This option will work all the time as long as the keys
give the sort order.


Levente

>
> Thanks,
> Gilles
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside