using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Sortowanie { public partial class Form1 : Form { List listaLiczb = new List(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { listaLiczb.Add(numericUpDown1.Value); refresh(); } void refresh() { listBox1.Items.Clear(); foreach (decimal liczba in listaLiczb) listBox1.Items.Add(liczba); } private void button2_Click(object sender, EventArgs e) { for (int i = 0; i < listaLiczb.Count - 1; i++) { if(listaLiczb[i]>listaLiczb[i+1]) { decimal d = listaLiczb[i]; listaLiczb[i] = listaLiczb[i + 1]; listaLiczb[i + 1] = d; i = 0; } } refresh(); } } }