mask = np.arange(counts.max()) < counts[:, (None)]
grouped_2Darray = np.empty(mask.shape)
grouped_2Darray.fill(np.nan)
grouped_2Darray[mask] = v
out = np.nanmax(grouped_2Darray, 1)
numpy, get maximum of subsets