[Gambas-user] Sorting 2D arrays
Fabien Bodard
gambas.fr at gmail.com
Mon Aug 24 14:33:46 CEST 2020
Arf..
make a class
'Class CEpisode
Static Public SortMode As Integer
Public Enum bySeriesName, byEpisodeName, byEpisodeNumber '... etc
Public SeriesName As String
Public EpisodeName As String
Public EpisodeNumber As Integer
Public EpisodeDescription As String
Public EpisodeDatePublished As String
Public EpisodeIdentifier As String
Public SeriesDescription As String
Public Sub _Compare(Other As CEpisode) As Integer
Select Case SortMode
Case bySerieName
Return Comp(Me.SeriesName, Other.SeriesName)
Case ByEpisodeName
Return Comp(Me.EpisodeName, Other.EpisodeName)
Case ByEpisodNumber
If Me.EpisodeNumber < Other.EpisodeNumber Then Return -1
If Me.EpisodeNumber < Other.EpisodeNumber Then Return 1
Return
'etc...
End Select
End
Use :
Private Episodes as new CEpisode[]
...
dim hEpisode as CEpisode
do
hepisode = new Cepisode
hepisode.EpisodeName = Value
...etc
loop
Episodes.SortMode = CEpisode.byEpisodeName
Episode.Sort
:-)
Le lun. 24 août 2020 à 09:45, Gianluigi <bagonergi at gmail.com> a écrit :
>
>
>
> Il giorno lun 24 ago 2020 alle ore 09:03 John Rose <john.aaron.rose at mailbox.org> ha scritto:
>>
>>
>> I would like to sort aData using 2 of the 'fields' (SeriesName being
>> major & EpisodeName being minor). I've noticed that there is a Sort
>> method for a 1D array but not for a 2D array. Any ideas?
>
>
> As far as I understand, you have two possibilities: either you create a class like that of the attached project and with the _compare function you can also sort multiple columns together, or you download the DinamixMatrixExample project from the farm.
> They are somewhat dated projects I could have done better but they certainly give an idea.
>
> I attach a zip file to avoid problems with GMail
>
> Gianluigi
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
--
Fabien Bodard
More information about the User
mailing list