factor some sign/comparison code out

There is a number of use cases in the code for the sign (-1/0/1) value,
all implemented with nested ternary expressions. Factor two helper
functions out and make use of them

* numSign(): new function
* numCompare(): new function
* IPCmp(): use above
* compareDecomposedPortNames(): idem
* cmp_array_sizes(): idem