reordering function

Given a vector (or a matrix), returns an ordered vector (or a matrix with ordered vectors)