title: Passing undetermined number of arguments in R to the order() function
body: <p>I've gathered that the order function in R can be used to sort rows of a data frame/matrix by one or more columns of that object. The columns are passed as separate arguments to order, and order can handle a variable number of arguments.</p>
  
  <p>I would like to sort a data frame by all its columns, but I don't know the names or the number of columns in the data frame beforehand. In Python, one can unpack a list of objects as the arguments to a function (e.g. <code>zip(*mylist)</code> is <code>zip(mylist[0], mylist[1], etc...)</code>). Is there a similar way to do so in R? It would be nice to "unpack" the columns of a matrix when I call order.</p>
  
  <p>Is there another way in R to sort by multiple columns besides passing an arbitrary number of parameters?</p>
  
  <p>more thoughts:
  It seems like I cannot just package multiple unnamed items into a single object to pass to order. Nor can I think of a way to use a for loop, apply, or do.call to make arbitrary numbers of objects. There's something here: <a href="http://r.789695.n4.nabble.com/custom-sort-td888802.html" rel="nofollow">http://r.789695.n4.nabble.com/custom-sort-td888802.html</a>.</p>
  
  <p>Or... should I write a for loop to call order on each column, starting with the least priority one and ending with the column that would've been the first argument to order, reordering the rows each time and making sure that order sorts stably?</p>
  
  <p>Thanks.</p>