find median of unsorted array