sorts an array of named arrays by the supplied fields