Possible Duplicate:
Finding the median value of an array?
How to calculate mean, median, mode and range from a set of numbers
Combine QuickSort and Median selection algorithm
How can I find the median values of a randomly generated array?
For Example: It would give me an array like 88,23,93,65,22,43 . The code I'm using finds the middle number but it's not sorted.
Here is the code I'm using so far:
double Median()
{
int Middle = TheArrayAssingment.length / 2;
if (TheArrayAssingment.length%2 == 1)
{
return TheArrayAssingment[Middle];
}
else {
return (TheArrayAssingment[Middle-1] + TheArrayAssingment[Middle]) / 2.0;
}
}