[Gambas-user] Array.SortUsing() metod

Benoît Minisini g4mba5 at gmail.com
Fri Mar 8 18:05:03 CET 2019


Le 08/03/2019 à 18:02, Benoît Minisini a écrit :
> Le 08/03/2019 à 17:49, Gianluigi a écrit :
>>
>>
>> Il giorno ven 8 mar 2019 alle ore 17:45 Gianluigi <bagonergi at gmail.com 
>> <mailto:bagonergi at gmail.com>> ha scritto:
>>
>>     I know that today is not a good day for me, but a kind person could
>>     show me how the new Array.SortUsing() [0] method works.
>>
>>     TIA & Regards
>>     Gianluigi
>>
>>
>> In fact, I forgot the link :-(
>> [0] 
>> https://gitlab.com/gambas/gambas/commit/d668dadcf5eb887ae9bca2b5ed56c311319a51e1 
>>
>>
>> Regards
>> Gianluigi
>>
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
> 
> I didn't have the time to make the wiki page yet.
> 
> A.SortUsing(B) sorts the A array using the order defined by the B array.
> 
> For example :
> 
> A = ["A", "B", "C", "D", "E"]
> B = [4, 1, 2, 10, 8]
> 
> A.SortUsing(B)
> 
> Now A is ["B", "C", "A", "E", "D"]
> 

A few remarks:

- To do that, SortUsing() creates a temporary integer array of the same 
size as A.

- Of course A and B must be the same size.

- A is sorted by the using the substitution generated by B.Sort().

- Maybe I should add an optional Mode argument for the sort of the B array.

Regards,

-- 
Benoît Minisini


More information about the User mailing list