Creates a sorted stride perm matching the KEEPORDER behavior of the NpyIter object. Because this operates based on multiple input strides, the 'stride' member of the
npy_stride_sort_item would be useless and we simply argsort a list of indices instead.
The caller should have already validated that 'ndim' matches for every array in the arrays list.
Initialize the strideperm values to the identity.
This is the same as the custom stable insertion sort in the NpyIter object, but sorting in the reverse order as in the iterator. The iterator sorts from smallest stride to biggest stride (Fortran order), whereas here we sort from biggest stride to smallest stride (C order).
Set swap even if it's not ambiguous already, because in the case of conflicts between different operands, C-order wins.
Only set swap if it's still ambiguous
A comparison has been done, so it's no longer ambiguous
If the comparison was unambiguous, either shift 'ipos' to 'i1' or stop looking for an insertion point
Insert out_strideperm[i0] into the right place
References NPY_CORDER, and PyArray_Newshape().