2017-07-22 92 views
-1

我非常需要我的作业帮助,我有这样的代码整理int,但我需要做的是排序字符。C#数组,快速排序的字符

List<int> unsorted = new List<int> { 9, 8, 7, 6 }; 
public Form1() 
{ 
    InitializeComponent(); 

    foreach (int x in unsorted) 
    { 
     textBox2.text = textBox2.text + x.ToString() + ""; 
    } 
} 

private void button1_Click(object sender, EventArgs e) 
{ 
    List<int> result = new List<int>(quicksort(unsorted)); 
    showsort(result) 
} 

这个家庭作业将在午夜过去,我仍然无法弄清楚。提前致谢。

+1

quicksort某处的签名,有什么问题吗?你有没有实现快速排序算法,你注意到它不像你期望的那样工作? – Christos

+0

字符和整数几乎是相同的东西。应该完全一样,但用char而不是int –

+0

'quicksort'和'showort'的定义是什么? – Lee

回答

0

charint都实现IComparable接口。所以,你可能会改变你quicksort像这样

public List<T> quicksort<T>(List<T> a) where T : IComparable<T> 
{ 
} 

然后在您需要更换<运营商呼叫CompareTo和分析结果