[Gambas-user] Sort an array of Objects[] of different Class
Brian G
brian at westwoodsvcs.com
Tue Apr 21 22:53:49 CEST 2020
>It is posible to use the .Sort() method to sort an array of differnt
>Class of Objects based on a variable or property?
>I can't figure how to use special method _Compare( ???) if it's even
>possible.
>
>Thank you.
Create a collection with the value you want to sort as keys, and the object/class as the value
collections.add(myobject,value)
add all the keys to a string[] array
string[].add(value)
use string[].sort
read the objects from the collection...
for i as integer = 0 to string[].max
myobject = collection[string[i]]
..... ' what ever you want to do
next
substitute string[] and collection for what ever you dim them as
as long as the values are distinct
Maybe this will help
Thank You
Brian G
More information about the User
mailing list