ArraySort is agnostic of the type of elements in the array it sorts, so it needs to know the size of an item (elemsize), as well as a reference to a procedure that exchanges items (exchangeproc).
Use perl's list slice capability to extract the elements between $i and $j, sort them using comparator function $c, and then replace the slice in situ.