Re: [Vala] Sorting an array of instances.




static int cmp_foo(void* a, void* b)
{
      return ((Foo*)a)->val - ((Foo*)b)->val < 0 ? -1 : 1;
}


Use:
 (*((Foo**)a))->val

In
  Foo x;
x is a pointer if Foo is a class, but
an actual structure if Foo is a struct
(unless I misunderstood vala).

hand
Nor Jaidi Tuah





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]