Quicksort median pivot implemented in order to prevent worse cases.
Tests and comments improved. Submitted version 23:50 01/29/14