added a median function

Hi @gonuke, I added a median function, please let me know if you want it!
What if length == 0?  will this work?