... | ... | @@ -2630,7 +2630,6 @@ class SortAidProgram |
|
|
public static List<string> SortAidList(List<string> unsortedList)
|
|
|
{
|
|
|
unsortedList.Sort(); //맨 처음엔 문자열 기준으로 자동 정렬
|
|
|
//unsortedList.ForEach(Console.WriteLine);
|
|
|
|
|
|
int lowPos = 0; //swap을 위한 변수
|
|
|
|
... | ... | @@ -2644,35 +2643,23 @@ class SortAidProgram |
|
|
if (ExtractStringProgram.ExtractString(unsortedList[i], "", ".")
|
|
|
.Equals(ExtractStringProgram.ExtractString(unsortedList[j], "", ".")))
|
|
|
{
|
|
|
int numOfi; //i,j,lowPos의 값을 담기 위한 변수
|
|
|
//j,lowPos가 가리키는 값을 담기 위한 변수
|
|
|
int numOfj;
|
|
|
int numOfLowPos;
|
|
|
|
|
|
//'.'이후에 숫자만 있으면 바로 int로 형변환, 숫자와 문자가 섞여있다면 밑에서 ExtractString 이용해서 숫자만 추출
|
|
|
bool isConvertiblei = int.TryParse(unsortedList[i].Split('.').ElementAt(1), out numOfi);
|
|
|
bool isConvertiblej = int.TryParse(unsortedList[j].Split('.').ElementAt(1), out numOfj);
|
|
|
bool isConvertibleLowPos = int.TryParse(unsortedList[lowPos].Split('.').ElementAt(1), out numOfLowPos);
|
|
|
|
|
|
if (!isConvertiblei) numOfi = int.Parse(ExtractStringProgram.ExtractString(unsortedList[i], ".", "-"));
|
|
|
if (!isConvertiblej) numOfj = int.Parse(ExtractStringProgram.ExtractString(unsortedList[j], ".", "-"));
|
|
|
if (!isConvertibleLowPos) numOfLowPos = int.Parse(ExtractStringProgram.ExtractString(unsortedList[lowPos], ".", "-"));
|
|
|
|
|
|
//Console.WriteLine("numOfi = " + numOfi);
|
|
|
//Console.WriteLine("numOfj = " + numOfj);
|
|
|
//Console.WriteLine("numOfLowPos = " + numOfLowPos);
|
|
|
|
|
|
if (numOfLowPos > numOfj) lowPos = j; //'.' 뒤에 나오는 숫자만 추출해서 비교
|
|
|
//Console.WriteLine("losPos = " + lowPos);
|
|
|
//Console.WriteLine();
|
|
|
}
|
|
|
}
|
|
|
string temp = unsortedList[i]; //swap
|
|
|
unsortedList[i] = unsortedList[lowPos];
|
|
|
unsortedList[lowPos] = temp;
|
|
|
|
|
|
//unsortedList.ForEach(Console.WriteLine);
|
|
|
//Console.WriteLine();
|
|
|
|
|
|
}
|
|
|
return unsortedList;
|
|
|
}
|
... | ... | @@ -2697,6 +2684,6 @@ class SortAidProgram |
|
|
|
|
|
sortedList.ForEach(Console.WriteLine); //출력
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|