[Gambas-user] Sorting 2D arrays

John Rose john.aaron.rose at mailbox.org
Wed Sep 2 19:43:46 CEST 2020


On 27/08/2020 11:12, user-request at lists.gambas-basic.org wrote:
> Il giorno mer 26 ago 2020 alle ore 14:36 Gianluigi 
> <bagonergi at gmail.com <mailto:bagonergi at gmail.com>> ha scritto:
>
>
>     I am attaching something similar to what Fabien has suggested,
>     perhaps ...
>
>
> Hi JoHn,
>
> it is not easy for me to explain classes and objects (assuming I 
> understand them) in a language other than mine.
> In the last example I left Private $hGlobalObject As New Object[] and 
> Dim hObj As Object because when I wrote it, it had helped me in 
> understanding, in fact a class transforms into an object at the moment 
> of its instantiation (object = new class).
> Rereading the code it seems to me that this can be confusing, Dim hObj 
> As Object in Sub Main, should be written as Dim hSeries As CSeries and 
> Private $hGlobalObject As New Object[] should be written Private 
> $aSeries As New CSeries[]
>
> Hope it helps
> Gianluigi

Gianluigi,

Thanks for your app showing the use of class. I've amended your app for 
sorting corresponding arrays. I've amended it so that it sorts on a 
composite key (Series Name padded out to 15 characters with spaces & "|" 
& Episode Name padded out to 15 characters with spaces) which I require 
in my iRecorder app. This amended app (SortCorrespondingArrays) is 
attached. It compiles OK. But it gives a runtime error (Bad Argument in 
Main:42) on line:
Print hEpisode.CompositeKey & Space(19 - Len(CStr(hEpisode.CompositeKey)));

It must be obvious but I don't see the cause. Any ideas?

Also, I would like to only have the option of sorting on CompositeKey. 
What do I need to remove/change to do that?

-- 
John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20200902/b9c10e28/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SortCorrespondingArrays.tar.gz
Type: application/gzip
Size: 12950 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20200902/b9c10e28/attachment-0001.gz>


More information about the User mailing list