Added generalized 'shuffle' function.