<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sort_state(self, best_hyp_indices: mx.nd.NDArray):
 """ Sorts states according to k-best order from last step in beam search. """

        self.states = [mx.nd.take(ds, best_hyp_indices) for ds in self.states]