[Gambas-user] gb3: sorting an array-like structure

Benoît Minisini gambas at ...1...
Thu Jun 30 11:42:04 CEST 2011


> On 05/24/2011 02:37 PM, Matti wrote:
> > Hi Kevin,
> > 
> > this sorting problem is (at least to me) still unsolved.
> > I gave up and used a lousy workaround, reading the 2-dim array into a
> > 1-dim string array like "field1/field2", then sorting this and reading
> > the fields backward again.
> > See Examples/Image/Lighttable, the sorting subs.
> > Works ok with a few hundred pictures (tested up to 1200), but for your
> > amount of data it sure will be not practicable.
> > 
> > If somebody knows a solution, I would be glad, too.
> 
> Sweet Jesus, this is the sort of thing that makes me want to blow up my
> house and run down the street naked looking for someone's ass to kick.
> Now that that's said, what's up with this (attachment)?
> 
> I finally got around to trying to sort graphical objects by their y
> coordinate so they'd overlap properly, but it seems even with extensive
> jerry-rigging I still need to implement more of it. I think I need to
> offset the whole batch of numbers before I sort so they're either
> positive or negative, then offset them back after sorting to get the
> original values. Hacking is all good and well, but for a language as
> advanced and robust as gb there should be a better option. I know I'm
> looking a gift horse in the mouth by complaining, but sometimes when my
> hair catches fire I have to say something about it.
> 
> Sorry. Now to hack together a solution so I can see if my new rendering
> method works. :)

At the moment, the only clean way to sort objects through multiple fields is 
doing what I told in a previous mail: implementing the _compare() method.

Once Gambas knows how to compare two objects with the _compare() method, it 
can sort them.

Regards,

-- 
Benoît Minisini




More information about the User mailing list