Smart pascal source code
var
a: array of Integer;
function Cmp1(const a, b: Integer): Integer;
begin
Result := a - b;
end;
function Cmp2(const a, b: Integer): Integer;
begin
Result := b - a;
end;
procedure printData;
var
i: Integer;
begin
for i := 0 to a.High do
Writeln(a[i]);
end;
begin
a.Add(3,2,1,6,18,4);
//a.Sort(Cmp1); // we don't need to use a comparer function
a.Reverse;
printData; // 4,18,6,1,2,3
a.Reverse;
printData; //3,2,1,6,18,4
a.Sort();
printData; // 1,2,3,4,6,18
//a.Sort(Cmp2); // we don't need to use a comparer function
a.Reverse;
printData; // 18,6,4,3,2,1
function $CmpNum(a,b) { return a-b };
var a = [];
function printData() {
var i = 0;
var $temp1;
for(i=0,$temp1=a.length;i<$temp1;i++) {
WriteLn(a[i]);
}
};
a.push(3, 2, 1, 6, 18, 4);
a.reverse();
a.reverse();
a.sort($CmpNum);
a.reverse();
printData();