WIP implementation of sortarray