Find median using quick-sort partition method