Sort lacks the ability to provide any data to the compare callback. So i've added SortWeighted.
Example:
function dist(fromX, fromY, toX, toY: Integer): Extended;
begin
Result := Hypot(fromX-toX, fromY-toY);
end;
var
points: array of record x,y: Integer; end;
weights: array of Extended;
i: Integer;
begin
points += [200,200];
points += [100,100];
points += [150,150];
points += [75, 75];
points += [80, 80];
for i:=0 to High(points) do
weights += dist(points[i].x, points[i].y, 100, 100);
SortWeighted(points, weights); // points are now sorted from 100,100
weights must either be array of Int64 or array of Extended
Sort
lacks the ability to provide any data to the compare callback. So i've addedSortWeighted
. Example:weights
must either bearray of Int64
orarray of Extended
SortedWeighted
(which returns a copy) also added.Sort
was also cleaned up.