groups = X.groupby('user').apply(lambda x: x.sort_values('order').value.values)
X_prime = pd.DataFrame(data=[i.astype(np.int) for i in groups.values],
    index=groups.index)
Groupby and reshape long to wide formatted dataframe while aggregating elements as arrays