Sort method using custom function



Array Sort method.
Smart pascal source code
function Ascending(a, b: Integer): Integer; begin Result := a - b; end; function Descending(a, b: Integer): Integer; begin Result := b - a; end; { unit1.pas } var a: array of Integer; i: integer; Begin a := [1,3,2,5,4]; a.Sort(@Ascending); for i in a do Writeln(i); // 1 2 3 4 5 Writeln(''); a := [1,3,2,5,4]; a.Sort(Descending); for i in a do Writeln(i); Writeln(''); // 5 4 3 2 1