V4RB, syntax for sorting of sets.

Sims, John AYU8 at CDC.GOV
Wed Oct 6 08:33:24 CDT 2004


Ruslan said:
> Hi all,
> 
> I want discuss one point.
> 
> So let we have selection as result of Find()
> 
>     dim set as Vset
> 
> Now I add to Vtable class new method
> 
>     Sort( set, fld, Ascending ) as VSet
> 
> This method allow us to sort selection of found records by 
> single field. Also we must to have other function, that will 
> allow us sort by few fields.
> 
> It can looks for example as
> 
>     Sort( set, order() as VSortPair ) as VSet
> 
> 
> Then in REALbasic code we could do
> 
>     dim order as array  ?
> 
>     order(1) = new VSortPair( f1, kAsc )
>     order(2) = new VSortPair( f3, kDesc )
>     order(3) = new VSortPair( f2, kAsc )
> 
>     SortedSet = t.Sort( set, order )
> 
> 
> Do you like such syntax?
> 
> It seems we have no other way for RB...
> 

Hi Ruslan,

I personally think that would work fine.  I have one question.  Are the
fields (f1,f2,f3) in your example Vfields or the name of the field as a
string -- or could we have both :-)  ?

FYI, REALbasic doesn't have a "dim as array", the REALbasic code would
look something like...

Dim order() as VSortPair

Order.append(new VSortPair( f1, kAsc ))
Order.append(new VSortPair( f3, kDesc ))
Order.append(new VSortPair( f2, kAsc ))

SortedSet = t.Sort( set, order )

Take care and keep up the good work.

-John


More information about the Valentina-beta mailing list