Re: [Gambas-user] gb3: sorting an array-like structure
Brought to you by:
gambas
From: Jussi L. <jus...@gm...> - 2011-05-24 15:50:57
|
Not sure, but I think Benoit means special method "_compare" which is used (if exist) to sort objects. http://gambasdoc.org/help/lang/special/compare?view http://gambasdoc.org/help/comp/gb/object%5B%5D/sort?v3 Jussi On Tue, May 24, 2011 at 05:22, Kevin Fishburne < kev...@ei...> wrote: > On 05/23/2011 10:01 PM, Kevin Fishburne wrote: > > On 05/09/2011 09:59 PM, Benoît Minisini wrote: > >>> Think of it like a spreadsheet instead of an array. I need each "row" > >>> sorted by the value in a "column". The two column values are > >>> ObjectNumber and ObjectY and the row represents the array index. > >>> > >>> There's got to be something like this in GAMBAS, but if not I can start > >>> Google searching sort algorithms and make a procedure. > >> > >> - Put the objects you have to draw on the screen in a temporary array. > >> - Define the (X,Y) final coordinates in two object variables. > >> - Implement the "_sort" special method in the object class. > >> > >> That way, you just have to call "Sort" to sort only the objects you want > the > >> way you want. > > > > The documentation didn't do much to alleviate my confusion, so if anyone > > understands this could you please post the simplest example possible? A > > link to the documentation on the _sort special method might be enough (I > > couldn't find it). As a refresher I'm basically trying to sort an array > > by one of its elements, much like sorting a spreadsheet > > Looks like Matti had the same question back in 2009: > > > http://old.nabble.com/sort-multidimensional-arrays-td26051359.html#a26059190 > > The proposed solution sounds similar to the response given to me, though > my feeble brain isn't able to convert it into code. Interesting that the > post mentions a variant can be used as well as an object. > > Matti, if you're out there, do you have an example of how you sorted the > example array in your post using these (or other) techniques? > > -- > Kevin Fishburne > Eight Virtues > www: http://sales.eightvirtues.com > e-mail: sa...@ei... > phone: (770) 853-6271 > > > > ------------------------------------------------------------------------------ > vRanger cuts backup time in half-while increasing security. > With the market-leading solution for virtual backup and recovery, > you get blazing-fast, flexible, and affordable data protection. > Download your free trial now. > http://p.sf.net/sfu/quest-d2dcopy1 > _______________________________________________ > Gambas-user mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user > |