adding ability to order by input, and compute intersection