I make heavy use of the following when presenting information to users so that they see items in natural order:
from java.util.concurrent import ConcurrentSkipListMap
from com.inductiveautomation.ignition.common.util import Comparators
ciAlnumCmp = Comparators.alphaNumeric(False)
def someAPI():
someOutput = ConcurrentSkipListMap(ciAlnumCmp)
for ....:
someOutput.put(someKey, someContent)
return someOutput
This pattern delivers a duck-typed dictionary that will use the human-friendly natural order of the keys when iterating over the keys or the items.
Which is wonderful when working purely in Perspective or Vision, but not so great when using RPC in any form. Because Ignition's Comparator class is not marked serializable. And even if it were, it actually hands out an instance of com.jidesoft.comparator.AlphanumComparator
. Which also is not marked serializable.
In other words, putting @system.util.runInGateway
ahead of that example def
blows up when you call that from Vision or a designer. Gateway to gateway requests would also blow up.
A wrapper class around the JideSoft class, marked serializable, is probably all that's needed. But cannot be jython, as jython classes are never serializable.
I'm inclined to add this to my Integration Toolkit, but I'd be happier if it happened 1st party....