Cast sortindex to int

Fixes issue #7