First author goes to the person who did the most manual work: experiments and writing and contributed solidly from an intellectual standpoint. This is the best spot for a trainee. Last author may either be: The middle author who contributed the least to the project.