@RichNaoo said:
My guess is it's sorting based on object id or some hash of the object, to use the label property as sorting index use the Array.custom_sort(MyComparatorClass, "my_comparator")
where you can specify the way the labels should be compared. See docs for more information.
i = i.label
or i = str(i.label)
results in i no longer being a reference to the object but being a direct reference to the label of i. In your code example this wouldn't result in anything.
And on top of that it's possible that i.get("label")
returns null if there is no property label in object i
which would cause a nullpointer reference error in the else part of your if statement.
Thanks for your suggestions, Rich.
If I can successfully get an array of the nodes' labels, and put the sort()
call after that, I shouldn't need to make a custom sort. As far as I understand it. So, that was my plan.
All I'm trying to do is just that: convert each entry in the array from a node reference to a string, which is contained in that node's label variable.
I understand the possibility for `i.get("label") to return null, but don't worry about that. The character script has that side covered, and this is just a li'l test anyway. Appreciate the thought, though.
--Hold on...
*Typey-type type*
Aaaaand I got it working.

It suddenly struck me as I was finishing up my response: I should just make another array and put the labels in that, instead.

Sorting it even works properly, 'cause all of its entries are simple strings.
Thanks again for the suggestions, either way! I think your "reference to the object, direct reference to the label" line kicked my brain in the right direction.