Well what you try to measure is distance.
No, it's a compare function and if all aspects of the types are identical a "fallback" is to compare the pointers directly.
function CompareSynEditMarks(Mark1, Mark2: Pointer): Integer;
var
m1: TSynEditMark absolute Mark1;
m2: TSynEditMark absolute Mark2;
begin
case m1.MarkLine.FCurrentSort1 of
smsoColumn: Result := m2.Column - m1.Column;
smsoPriority: Result := m2.Priority - m1.Priority;
smsoBookmarkFirst:
if (m1.IsBookmark) and (not m2.IsBookmark) then Result := -1
else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := 1
else Result := 0;
smsoBookMarkLast:
if (m1.IsBookmark) and (not m2.IsBookmark) then Result := 1
else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := -1
else Result := 0;
else
Result := 0;
end;
if Result <> 0 then
exit;
case m1.MarkLine.FCurrentSort2 of
smsoColumn: Result := m2.Column - m1.Column;
smsoPriority: Result := m2.Priority - m1.Priority;
smsoBookmarkFirst:
if (m1.IsBookmark) and (not m2.IsBookmark) then Result := -1
else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := 1
else Result := 0;
smsoBookMarkLast:
if (m1.IsBookmark) and (not m2.IsBookmark) then Result := 1
else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := -1
else Result := 0;
else
Result := 0;
end;
if Result <> 0 then
exit;
Result := m2.Column - m1.Column;
if Result <> 0 then
exit;
Result := m2.Priority - m1.Priority;
if Result <> 0 then
exit;
Result := PtrInt(m2) - PtrInt(m1); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
end;