On Sun, 18 May 2014, Beno?t Minisini wrote: > Le 14/05/2014 21:38, Tobias Boege a ?crit : > > Hi Benoit, > > > > when we wanted to sort a 2d array (table) by a specific column, variable at > > runtime, we did the following: > > > > 1. Create the class, let's call it "Record", to represent the table > > records which implements a _compare() method and has a SortField > > property which indicates to _compare() which column we want to sort > > by. > > 2. Create a class "RecordGroup" which Inherits Object[] and has a > > SortField(Field As Integer, Optional Mode As Integer) method which is > > a multicolumn-aware version of Sort: > > > > Public Sub SortField(Field As Integer, Optional Mode As Integer) > > Dim iInd As Integer > > > > For iInd = 0 To Super.Count - 1 > > Super[iInd].SortField = Field > > Next > > Super.Sort(Mode) > > End > > 3. Then, we must work with RecordGroups which we can sort by, say, column > > 7 > > using myGroup.SortField(7). > > > > You see that we need to set each object's SortField property to the Field > > value in order to make the _compare()s work together as we desire. If some > > objects "don't get it", we will lose transitivity of our relation and the > > sort may fail. > > > > We can't use static properties in the Record class either because we may > > want to have multiple groups. > > I don't understand that: if the sort field is a parameter of the sort, > then you can store it inside a static variable just during the sort. >
Hmm... that's an idea, indeed! Because we can ensure that no parallel sorts mess up the static variable. Too bad that this is a good solution. We were already excited about this potential new feature :-) Regards, Tobi -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user