Sorts ndarrays in place