[Lazarus] TFPGList.Sort

Maciej Izak hnb.code at gmail.com
Thu Oct 8 16:57:05 CEST 2015


As alternative you can use https://github.com/dathox/generics.collections
(requires FPC 3.0).

You can use TList<> from Generics.Collections, is much simpler in usage:

======code begin======
type
  TIntegerList = specialize TList<Integer>;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  il: TIntegerList;
begin
  il:= TIntegerList.Create;
  il.add(5);
  il.Add(3);
  il.add(8);
  il.Add(2);
  il.add(2);
  il.Add(1);
  ListBox1.Clear;
  for i:= 0 to il.Count - 1 do
    ListBox1.Items.Add(IntToStr(il[i]));
  il.Sort();
  ListBox2.Clear;
  for i:= 0 to il.Count - 1 do
    ListBox2.Items.Add(IntToStr(il[i]));
  il.Free;
end;
======code end======
-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20151008/c1e1eb01/attachment-0003.html>


More information about the Lazarus mailing list