public void ChoiceSort(string[] arrPrice)
{//优化3点:arrPrice.Length -1(最后一次不用比较了)、j = i + 1(已经比较过了)、if (minIndex != i)不用交换
Double temp = 0;
int minIndex = 0;
for (int i = 0; i < arrPrice.Length -1; i++)
{
minIndex = i;
for (int j = i + 1; j < arrPrice.Length; j++)
{
if (Convert.ToDouble(arrPrice[j]) < Convert.ToDouble(arrPrice[minIndex]))
{
minIndex = j;
}
}
if (minIndex != i)
{
temp = Convert.ToDouble(arrPrice[minIndex]);
arrPrice[minIndex] = arrPrice[i];
arrPrice[i] = Convert.ToString(temp);
}
}
}