I'm actually taking a course about doing reseach and this is what the text and my prof say.
First author is given to the person who came up with the project and is make the decisions about where to go next. And/or has the most responsibility. It doesn't matter if this person never touches a flask. Even if s/he has an assistant do all the work, if the assistant hasn't contributed to the intelectual part of the research, they don't even get co-authorship, they go under acknowledgments.
Most of the time if you are an undergrad, or are working with a mentor, the main prof that actually deserves the first author title will give to the person working with them so it will help the assistant get a start in the scientific field.