private void button7_Click(object sender, EventArgs e) { string[] wartosci = Par1_TB.Text.Split(' '); porownajNapisy por = (string x, string y) => { return(x.CompareTo(y)); }; sortuj(wartosci, por); wynik_LB.Text = null; foreach (string item in wartosci) { wynik_LB.Text += item.ToString() + " "; } }
public void sortuj(string[] tablica, porownajNapisy delegat) { string tmp; int n = tablica.Length; do { for (int i = 0; i < n - 1; i++) { if (delegat(tablica[i], tablica[i + 1]) > 0) { tmp = tablica[i]; tablica[i] = tablica[i + 1]; tablica[i + 1] = tmp; } } n--; } while (n > 1); }