<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFBinaryHeapCallBacks/compare",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@SA@CFBinaryHeapCallBacks@FI@compare"
  },
  "title" : "compare"
}
-->

# compare

The callback used to compare values in the binary heap in some operations. This field cannot be `NULL`.

```
var compare: ((UnsafeRawPointer?, UnsafeRawPointer?, UnsafeMutableRawPointer?) -> CFComparisonResult)!
```

## Parameters

`ptr1`

First value to compare.

`ptr2`

Second value to compare.

`info`

Not used. Should always be `NULL`.

## Return Value

[`CFComparisonResult.compareLessThan`](/documentation/CoreFoundation/CFComparisonResult/compareLessThan) if `ptr1` is less than `ptr2`, [`CFComparisonResult.compareEqualTo`](/documentation/CoreFoundation/CFComparisonResult/compareEqualTo) if `ptr1` and `ptr2` are equal, or [`CFComparisonResult.compareGreaterThan`](/documentation/CoreFoundation/CFComparisonResult/compareGreaterThan) if `ptr1` is greater than `ptr2`.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)