[Gambas-user] Sort an array of Objects[] of different Class

Jussi Lahtinen jussi.lahtinen at gmail.com
Tue Apr 21 23:39:57 CEST 2020


Interesting problem.
I suggest you make the object inherit the same class, which is base for the
comparison, but if you cannot do that, then you need to implement the same
things in every class. See attachment for that.


Jussi

On Tue, Apr 21, 2020 at 11:27 PM martin p cristia <tercoide at hotmail.com>
wrote:

> It is posible to use the .Sort() method to sort an array of differnt
> Class of Objects based on a variable or property?
>
> dim myDifObj as New Object[]
>
> dim thing1 as New Class1(4) ' The class saves that number for sorting
>
> myDifObj.Add(thing1)
>
> dim thing2 as New OtherClass(3) ' The class saves that number for sorting
>
> myDifObj.Add(thing2)
>
> dim thing3 as New anOtherClass(5) ' The class saves that number for sorting
>
> myDifObj.Add(thing3)
>
>
> myDifObj.Sort()  ???
>
>
> I can't figure how to use special method _Compare( ???)  if it's even
> possible.
>
> Thank you.
>
>
>
> --
> Saludos
>
> Ing. Martin P Cristia
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200422/1593024f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SortObjects-0.0.1.tar.gz
Type: application/gzip
Size: 11788 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200422/1593024f/attachment-0001.gz>


More information about the User mailing list