In my experience the lead author is always the post doc or grad student who actually did the research and wrote the paper, while the advisor is the last author and they developed the grant to fund both the grad student and post doc. If you collaborate with another lab, their post docs go towards the front behind your name and the advisor goes somewhere at the end. If two people equally wrote a paper they might be 1 and 2 and get an asterisk indicating they are both co first authors. If anyone was involved at all in the work e.g data collection or anyone involved with running an assay they go somewhere in the middle. Perhaps it’s different in other fields