Re: sorting data in simplelist

On Jul 7, 2005, at 9:33 AM, Beast wrote:

I have SimpleList which should be ordered by some column, what is the prefered way, sort the data before pushing into the stack or push data as is and then sort using SimpleList (possible??).
Some example would be greatly appreciated :)

It may not be the most efficient thing in the world, but you can use normal perl sorting stuff on the tied data array.

  @{ $slist->{data} } = sort \&my_cool_sort_func, @{ $slist->{data} };

The simplelist's model is just a ListStore, which implements the TreeSortable interface, so you should be able to set sort columns and all that stuff quite normally.

  $slist->get_model->set_sort_column_id ($index, 'ascending');

A few weeks ago there was discussion about using a TreeModelFilter with SimpleList; you could probably use the same Evil Tricks with as TreeModelSort. (Requires bleeding edge code, though.)

Brian: If i recall correctly, this is the physics department.
Chris: That explains all that gravity.
    -- Family Guy, "The Story on Page One"

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]