Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

[] Bir listeyi alfabetik olarak sıralama

{İhtiyacınız olan sadece bir TListBox ve bir TButton. Basit birkaç düzenleme ile TStringList'de de kullanabilirsiniz. if clause'daki "<" operatörü yerine ">" kullanırsanırsanız sıralama yön değiştirir} procedure TForm1.Button1Click(Sender: TObject); var i, x: Integer; begin for i := 0 to (ListBox1.Items.Count - 1) do for x := 0 to (ListBox1.Items.Count - 1) do if (ListBox1.Items[x] < ListBox1.Items[i]) and (x > i) then begin ListBox1.Items.Insert(i, ListBox1.Items[x]); ListBox1.Items.Delete(x + 1); end; end;