0
Answered

Aot List Sort, "IComparer" ? (sorting objects by int value)

Bread 1 year ago updated by Lazlo Bonin (Lead Developer) 1 year ago 1

Hi everyone,

I tried to make a lambda expression within Bolt, but I ended up confused about which units I should use to achieve that, right now I'm trying to use the Aot List.Sort unit to sort a bunch of objects with a certain int value, I can't understand which unit should go with the comparer input... How do you achieve something like this?

collEquipment.Sort((x, y) => y.ID.CompareTo(x.ID));

Thanks for your time and sorry for the lack of details (assuming I needed to be more specific), the only thing I found that was similar is this topic: https://support.ludiq.io/communities/5/topics/2741-how-to-listsortcomparer it has no answers tho. Again, thanks.

Bolt Version:
1.4.3f2
Unity Version:
2018.4.0f1
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+1
Answered

Hi Bread,

Unfortunately, lambda expressions and delegates are not available in Bolt 1.

In Bolt 2, currently in Alpha, you could easily use the new delegate units to invoke that Sort.

In Bolt 1, you will need to create a wrapper C# method that does the sorting for you and call that from Bolt.

Sorry for the inconvenience!